mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: Add Graceful Plugin Shutdown to Runner
This change introduces a shutdown lifecycle hook for plugins. The `PluginManager` now has an `async def shutdown()` method that will call `await plugin.shutdown()` on any registered plugins that implement the method. This is called from `Runner.close()`, allowing plugins to perform cleanup tasks like flushing logs or closing connections when the runner instance is being closed. This improves the reliability of plugins that perform background operations. PiperOrigin-RevId: 831037737
This commit is contained in:
committed by
Copybara-Service
parent
01bac62f0c
commit
249216e890
@@ -455,7 +455,7 @@ class BigQueryAgentAnalyticsPlugin(BasePlugin):
|
||||
self._background_tasks.add(task)
|
||||
task.add_done_callback(self._background_tasks.discard)
|
||||
|
||||
async def shutdown(self):
|
||||
async def close(self):
|
||||
"""Flushes pending logs and closes client."""
|
||||
# 1. Wait for pending background logs (best effort, 2s timeout)
|
||||
if self._background_tasks:
|
||||
|
||||
Reference in New Issue
Block a user