mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
parent
a02fd034e4
commit
c7bd51b56f
1 changed files with 10 additions and 3 deletions
|
|
@ -457,11 +457,18 @@ class WorkerQueue(object):
|
||||||
self._max_workers = max_workers
|
self._max_workers = max_workers
|
||||||
|
|
||||||
def _worker(self):
|
def _worker(self):
|
||||||
|
# This is a daemon thread. Since the global namespace is going to
|
||||||
|
# vanish on interpreter shutdown, redefine everything from the global
|
||||||
|
# namespace here.
|
||||||
|
_TypeError = TypeError
|
||||||
|
_Empty = queue.Empty
|
||||||
|
_handle_cli_error = handle_cli_error
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
func = self._queue.get()
|
func = self._queue.get()
|
||||||
except (TypeError, queue.Empty):
|
except (_TypeError, _Empty):
|
||||||
# TypeError might be raised if vdirsyncer just finished
|
# Any kind of error might be raised if vdirsyncer just finished
|
||||||
# processing all items and the interpreter is shutting down,
|
# processing all items and the interpreter is shutting down,
|
||||||
# yet the workers try to get new tasks.
|
# yet the workers try to get new tasks.
|
||||||
# https://github.com/untitaker/vdirsyncer/issues/167
|
# https://github.com/untitaker/vdirsyncer/issues/167
|
||||||
|
|
@ -471,7 +478,7 @@ class WorkerQueue(object):
|
||||||
try:
|
try:
|
||||||
func(wq=self)
|
func(wq=self)
|
||||||
except:
|
except:
|
||||||
if not handle_cli_error():
|
if not _handle_cli_error():
|
||||||
self._exceptions.append(sys.exc_info()[1])
|
self._exceptions.append(sys.exc_info()[1])
|
||||||
finally:
|
finally:
|
||||||
self._queue.task_done()
|
self._queue.task_done()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue