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