def _deferToThreadPool(self, f, *args, **kwargs):
"""Defer execution of ``f(*args, **kwargs)`` to the thread pool.
This returns a deferred which will callback with the result of
that expression, or errback with a failure wrapping the raised
exception.
"""
if self._pool.joined:
return fail(
ReactorNotRunning("This thimble's threadpool already stopped.")
)
if not self._pool.started:
self._pool.start()
self._reactor.addSystemEventTrigger(
'during', 'shutdown', self._pool.stop)
return deferToThreadPool(self._reactor, self._pool, f, *args, **kwargs)
评论列表
文章目录