Skip to content

Commit

Permalink
Make sure we only pull when queue is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
awlx committed Sep 18, 2023
1 parent be25855 commit 32217a7
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions wgkex/worker/msg_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ def watch_queue() -> None:
def pick_from_queue() -> None:
"""Picks a message from the queue and processes it."""
logger.debug("Starting queue processor")
while q.empty() is False:
domain, message = q.get()
logger.debug("Processing queue item %s for domain %s", message, domain)
client = WireGuardClient(
public_key=str(message.payload.decode("utf-8")),
domain=domain,
remove=False,
)
logger.info(
f"Processing queue for key {client.public_key} on domain {domain} with lladdr {client.lladdr}"
)
logger.debug(link_handler(client))
q.task_done()
while True:
if not q.empty():
domain, message = q.get()
logger.debug("Processing queue item %s for domain %s", message, domain)
client = WireGuardClient(
public_key=str(message.payload.decode("utf-8")),
domain=domain,
remove=False,
)
logger.info(
f"Processing queue for key {client.public_key} on domain {domain} with lladdr {client.lladdr}"
)
logger.debug(link_handler(client))
q.task_done()

0 comments on commit 32217a7

Please sign in to comment.