Commit 46d0a3d0 authored by Michael Hanselmann's avatar Michael Hanselmann

workerpool: Don't keep reference to task arguments

The workerpool should not keep any reference to task arguments after
they were processed by RunTask. Doing so led to jobs being cached
by the job queue's WeakValueDictionary for longer than they should've
been.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarManuel Franceschini <livewire@google.com>
parent 5d297d8a
......@@ -78,9 +78,8 @@ class BaseWorker(threading.Thread, object):
"""
pool = self.pool
assert self._current_task is None
while True:
assert self._current_task is None
try:
# Wait on lock to be told either to terminate or to do a task
pool._lock.acquire()
......@@ -97,7 +96,11 @@ class BaseWorker(threading.Thread, object):
self._current_task = task
# No longer needed, dispose of reference
del task
assert self._HasRunningTaskUnlocked()
finally:
pool._lock.release()
......
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