Skip to content

Commit

Permalink
simplify while loop when listening for synchronizer messages
Browse files Browse the repository at this point in the history
  • Loading branch information
djantzen committed Jan 29, 2025
1 parent da3992a commit 0856151
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugin_runner/plugin_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,10 @@ async def synchronize_plugins(max_iterations: None | int = None) -> None:
await pubsub.psubscribe(CHANNEL_NAME)
log.info("Listening for messages on pubsub channel")
iterations: int = 0
while True:
if max_iterations is not None: # max_iterations == -1 means infinite iterations
if iterations >= max_iterations:
break
iterations += 1
while (
max_iterations is None or iterations < max_iterations
): # max_iterations == -1 means infinite iterations
iterations += 1
message = await pubsub.get_message(ignore_subscribe_messages=True)
if message is not None:
log.info("Received message from pubsub channel")
Expand Down

0 comments on commit 0856151

Please sign in to comment.