Commit 2db05c94 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

workerpool: Use loop to ignore spurious notifications



This saves us from returning to the worker code when there is no
task to be processed.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent c8d0be94
......@@ -354,18 +354,18 @@ class WorkerPool(object):
if not self._tasks:
logging.debug("Waiting for tasks")
# wait() releases the lock and sleeps until notified
self._pool_to_worker.wait()
while True:
# wait() releases the lock and sleeps until notified
self._pool_to_worker.wait()
logging.debug("Notified while waiting")
logging.debug("Notified while waiting")
# Were we woken up in order to terminate?
if self._ShouldWorkerTerminateUnlocked(worker):
return _TERMINATE
# Were we woken up in order to terminate?
if self._ShouldWorkerTerminateUnlocked(worker):
return _TERMINATE
if not self._tasks:
# Spurious notification, ignore
return None
if self._tasks:
break
# Get task from queue and tell pool about it
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment