mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-06 02:13:43 +02:00
Explicitly close all connections instead of relying on GC
This commit is contained in:
parent
46fe62e45f
commit
cce5a0d894
1 changed files with 8 additions and 0 deletions
|
|
@ -224,6 +224,8 @@ def failed(self):
|
|||
return self.terminal_failure is not None
|
||||
|
||||
def terminal_error(self):
|
||||
if self.shutting_down:
|
||||
return
|
||||
for worker, job in self.busy_workers.iteritems():
|
||||
self.results.put(WorkerResult(job.id, Result(None, None, None), True, worker))
|
||||
self.tracker.task_done()
|
||||
|
|
@ -234,6 +236,7 @@ def terminal_error(self):
|
|||
self.shutdown()
|
||||
|
||||
def shutdown_workers(self, wait_time=0.1):
|
||||
self.worker_data = self.common_data = None
|
||||
for worker in self.busy_workers:
|
||||
if worker.process.poll() is None:
|
||||
try:
|
||||
|
|
@ -257,6 +260,11 @@ def join():
|
|||
reaper.daemon = True
|
||||
reaper.start()
|
||||
reaper.join(wait_time)
|
||||
for w in self.available_workers + list(self.busy_workers):
|
||||
try:
|
||||
w.conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
for w in workers:
|
||||
if w.poll() is None:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue