summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-03-26 20:50:08 +0000
committerGerrit Code Review <review@openstack.org>2015-03-26 20:50:08 +0000
commit9035599e90190abc2bc834dd0478fc4a9ba3498f (patch)
tree1581787d824288d17a6a11837e14c9ca97ce98b2
parent0b6bf90f3dbbfb807790db1408e83ba5a58e792a (diff)
parent4c8fc8cd1dcba5c933235b18b0edfe8f099cffd1 (diff)
downloadgear-9035599e90190abc2bc834dd0478fc4a9ba3498f.tar.gz
Merge "Move running check in getJob"0.5.6
-rw-r--r--gear/__init__.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/gear/__init__.py b/gear/__init__.py
index 2069f92..b4306a4 100644
--- a/gear/__init__.py
+++ b/gear/__init__.py
@@ -1845,6 +1845,14 @@ class Worker(BaseClient):
"""
self.job_lock.acquire()
try:
+ # self.running gets cleared during _shutdown(), before the
+ # stopWaitingForJobs() is called. This check has to
+ # happen with the job_lock held, otherwise there would be
+ # a window for race conditions between manipulation of
+ # "running" and "waiting_for_jobs".
+ if not self.running:
+ raise InterruptedError()
+
self.waiting_for_jobs += 1
self.log.debug("Get job; number of threads waiting for jobs: %s" %
self.waiting_for_jobs)
@@ -1857,13 +1865,6 @@ class Worker(BaseClient):
if not job:
self._updateStateMachines()
- # That variable get cleared during _shutdown(), before the
- # stopWaitingForJobs() is called. The check has to happen with the
- # self.job_lock held, otherwise there would be a window for race
- # conditions between manipulation of "running" and
- # "waiting_for_jobs".
- if not self.running:
- raise InterruptedError()
finally:
self.job_lock.release()