workerpool: Don't notify if there was no task
authorMichael Hanselmann <hansmi@google.com>
Tue, 8 Jul 2008 15:03:50 +0000 (15:03 +0000)
committerMichael Hanselmann <hansmi@google.com>
Tue, 8 Jul 2008 15:03:50 +0000 (15:03 +0000)
commitb3558df1ce05334d20560d16cec79e7e4286ae09
tree984465a798904fb223665ed4000196e78b11ffcd
parent195c7f914657e46ce26900311b0ac74df99d8be2
workerpool: Don't notify if there was no task

Workers have to notify their pool if they finished a task to make
the WorkerPool.Quiesce function work. This is done in the finally:
clause to notify even in case of an exception. However, before
we notified on each run, even if there was no task, thereby creating
some sort of an endless loop of notifications. In a future patch
we should split the single condition object into several to
produce less spurious notifications.

While we're at this, this patch also adds two new functions to
BaseWorker to query whether it's currently running a task and then
uses one of these functions in the WorkerPool instead of querying
the internal variable directly.

Reviewed-by: iustinp
lib/workerpool.py