From f6872e77cf1a9ede778295360f973add1386fcc9 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 12 Feb 2020 19:12:12 -0800 Subject: [PATCH] Make job._joinme_lock private to discourage outside editing. --- voussoirkit/threadpool.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/voussoirkit/threadpool.py b/voussoirkit/threadpool.py index 675f912..d7d4388 100644 --- a/voussoirkit/threadpool.py +++ b/voussoirkit/threadpool.py @@ -187,12 +187,12 @@ class Job: self.exception = NO_EXCEPTION self._thread = None - # joinme_lock works because it is possible for a single thread to block + # _joinme_lock works because it is possible for a single thread to block # itself by calling `lock.acquire()` twice. The first call is here, # and the second call is in `join` so that join will block until the # lock is released by the job's finishing phase. - self.joinme_lock = threading.Lock() - self.joinme_lock.acquire() + self._joinme_lock = threading.Lock() + self._joinme_lock.acquire() def __repr__(self): if self.name: @@ -204,8 +204,8 @@ class Job: ''' Block until this job runs and completes. ''' - self.joinme_lock.acquire() - self.joinme_lock.release() + self._joinme_lock.acquire() + self._joinme_lock.release() def start(self): ''' @@ -223,7 +223,7 @@ class Job: self.status = RAISED self._thread = None self.pool._job_finished() - self.joinme_lock.release() + self._joinme_lock.release() self.status = RUNNING self._thread = threading.Thread(target=do_it)