Skip to content

Commit

Permalink
fix looping in listener
Browse files Browse the repository at this point in the history
  • Loading branch information
djantzen committed Jan 29, 2025
1 parent cd41521 commit 44f863d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugin_runner/plugin_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,16 @@ async def ReloadPlugins(
yield ReloadPluginsResponse(success=True)


async def synchronize_plugins(max_iterations: int = -1) -> None:
async def synchronize_plugins(max_iterations: None | int = None) -> None:
"""Listen for messages on the pubsub channel that will indicate it is necessary to reinstall and reload plugins."""
client, pubsub = get_client()
await pubsub.psubscribe(CHANNEL_NAME)
log.info("Listening for messages on pubsub channel")
iterations: int = 0
while iterations < max_iterations:
if max_iterations > 0: # max_iterations == -1 means infinite iterations
while True:
if max_iterations is not None: # max_iterations == -1 means infinite iterations
if iterations >= max_iterations:
break
iterations += 1
message = await pubsub.get_message(ignore_subscribe_messages=True)
if message is not None:
Expand Down

0 comments on commit 44f863d

Please sign in to comment.