Skip to content

Commit

Permalink
Improved logging for queue join()
Browse files Browse the repository at this point in the history
  • Loading branch information
andresriancho committed May 20, 2019
1 parent 2695725 commit 99da115
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions w3af/core/data/misc/cached_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def _get(self):
return item

def join(self):
"""Blocks until all items in the Queue have been gotten and processed.
"""
Blocks until all items in the Queue have been gotten and processed.
The count of unfinished tasks goes up whenever an item is added to the
queue. The count goes down whenever a consumer thread calls task_done()
Expand All @@ -173,6 +174,11 @@ def join(self):
self.all_tasks_done.acquire()
try:
while self.unfinished_tasks:
self.all_tasks_done.wait()
result = self.all_tasks_done.wait(timeout=5)

if result is None:
msg = 'Still have %s unfinished tasks in %s join()'
args = (self.unfinished_tasks, self.name)
om.out.debug(msg % args)
finally:
self.all_tasks_done.release()

0 comments on commit 99da115

Please sign in to comment.