Skip to content

Commit 66b816c

Browse files
fix(mgr.py): Ensure plugin is fully registered before returning from restart_plugin
- Add 1s interval polling (30s timeout) for plugin registration - Prevent race condition where GET_PLUGIN_INFO returns stale data or "not found"
1 parent 0a13f15 commit 66b816c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • src/langbot_plugin/runtime/plugin

src/langbot_plugin/runtime/plugin/mgr.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,18 @@ async def restart_plugin(
466466
asyncio_task = asyncio.create_task(task)
467467
self.plugin_run_tasks.append(asyncio_task)
468468

469+
# Poll until the plugin appears in self.plugins (with timeout)
470+
plugin_key = f"{plugin_author}/{plugin_name}"
471+
for _ in range(30):
472+
if self.find_plugin(plugin_author, plugin_name) is not None:
473+
logger.info(f"Plugin {plugin_key} restarted and registered")
474+
break
475+
await asyncio.sleep(1)
476+
else:
477+
logger.warning(
478+
f"Plugin {plugin_key} restart timed out waiting for registration"
479+
)
480+
469481
yield {"current_action": "plugin restarted"}
470482
break
471483
else:

0 commit comments

Comments
 (0)