Simplify pool.join logic by just calling each job's join.
This commit is contained in:
parent
a1f26200fa
commit
b7a2c3b19b
1 changed files with 5 additions and 10 deletions
|
@ -70,8 +70,9 @@ class ThreadPool:
|
||||||
'''
|
'''
|
||||||
When a job finishes, it will call here.
|
When a job finishes, it will call here.
|
||||||
'''
|
'''
|
||||||
if self.closed or self.paused:
|
if self.paused:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.clear_done_and_start_jobs()
|
self.clear_done_and_start_jobs()
|
||||||
|
|
||||||
def assert_not_closed(self):
|
def assert_not_closed(self):
|
||||||
|
@ -136,15 +137,9 @@ class ThreadPool:
|
||||||
and block until all jobs are complete.
|
and block until all jobs are complete.
|
||||||
'''
|
'''
|
||||||
self.closed = True
|
self.closed = True
|
||||||
self.job_manager_lock.acquire()
|
self.clear_done_and_start_jobs()
|
||||||
while self.unfinished_count() > 0:
|
for job in self.jobs:
|
||||||
print('round')
|
job.join()
|
||||||
for job in self.jobs:
|
|
||||||
if job.thread:
|
|
||||||
print(job)
|
|
||||||
job.thread.join()
|
|
||||||
self._clear_done_and_start_jobs()
|
|
||||||
self.job_manager_lock.release()
|
|
||||||
|
|
||||||
def running_count(self):
|
def running_count(self):
|
||||||
return sum(1 for job in list(self.jobs) if job.status is RUNNING)
|
return sum(1 for job in list(self.jobs) if job.status is RUNNING)
|
||||||
|
|
Loading…
Reference in a new issue