|
|
@ -108,7 +108,8 @@ class _WorkerThread(threading.Thread, _IdleObject): |
|
|
|
|
|
|
|
|
|
|
|
def run(self): |
|
|
|
def run(self): |
|
|
|
# call the function |
|
|
|
# call the function |
|
|
|
_log.debug('Thread d %s calling %s', self.name, str(self._function)) |
|
|
|
_log.debug('Thread d %s calling %s', self.getName(), |
|
|
|
|
|
|
|
str(self._function)) |
|
|
|
|
|
|
|
|
|
|
|
args = self._args |
|
|
|
args = self._args |
|
|
|
kwargs = self._kwargs |
|
|
|
kwargs = self._kwargs |
|
|
@ -121,7 +122,7 @@ class _WorkerThread(threading.Thread, _IdleObject): |
|
|
|
self.emit("exception", exc) |
|
|
|
self.emit("exception", exc) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
_log.debug('Thread id %s completed', self.name) |
|
|
|
_log.debug('Thread id %s completed', self.getName()) |
|
|
|
|
|
|
|
|
|
|
|
self.emit("completed", result) |
|
|
|
self.emit("completed", result) |
|
|
|
return |
|
|
|
return |
|
|
@ -146,18 +147,18 @@ class _ThreadManager(object): |
|
|
|
|
|
|
|
|
|
|
|
# not actually a widget. It's the object that emitted the signal, in |
|
|
|
# not actually a widget. It's the object that emitted the signal, in |
|
|
|
# this case, the _WorkerThread object. |
|
|
|
# this case, the _WorkerThread object. |
|
|
|
thread_id = widget.name |
|
|
|
thread_id = widget.getName() |
|
|
|
|
|
|
|
|
|
|
|
_log.debug('Thread id %s completed, %d threads in the queue', thread_id, |
|
|
|
_log.debug('Thread id %s completed, %d threads in the queue', |
|
|
|
len(self._thread_pool)) |
|
|
|
thread_id, len(self._thread_pool)) |
|
|
|
|
|
|
|
|
|
|
|
self._running.remove(thread_id) |
|
|
|
self._running.remove(thread_id) |
|
|
|
|
|
|
|
|
|
|
|
if self._thread_pool: |
|
|
|
if self._thread_pool: |
|
|
|
if len(self._running) < self._max_threads: |
|
|
|
if len(self._running) < self._max_threads: |
|
|
|
next = self._thread_pool.pop() |
|
|
|
next = self._thread_pool.pop() |
|
|
|
_log.debug('Dequeuing thread %s', next.name) |
|
|
|
_log.debug('Dequeuing thread %s', next.getName()) |
|
|
|
self._running.append(next.name) |
|
|
|
self._running.append(next.getName()) |
|
|
|
next.start() |
|
|
|
next.start() |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
@ -171,7 +172,7 @@ class _ThreadManager(object): |
|
|
|
are parameters passed to the function.""" |
|
|
|
are parameters passed to the function.""" |
|
|
|
|
|
|
|
|
|
|
|
thread = _WorkerThread(func, *args, **kwargs) |
|
|
|
thread = _WorkerThread(func, *args, **kwargs) |
|
|
|
thread_id = '%s' % (self._thread_id) |
|
|
|
thread_id = '%s-%s' % (self._thread_id, func.__name__) |
|
|
|
|
|
|
|
|
|
|
|
thread.connect('completed', complete_cb) |
|
|
|
thread.connect('completed', complete_cb) |
|
|
|
thread.connect('completed', self._remove_thread) |
|
|
|
thread.connect('completed', self._remove_thread) |
|
|
|