本文整理匯總了Python中qtpy.QtCore.QThread方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QThread方法的具體用法?Python QtCore.QThread怎麽用?Python QtCore.QThread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qtpy.QtCore
的用法示例。
在下文中一共展示了QtCore.QThread方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: wait_connections_stopped
# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QThread [as 別名]
def wait_connections_stopped(self):
self.log.debug('Waiting for {} connections threads to stop'.format(len(self.threads)))
for thread in self.threads.copy():
try:
if not thread.wait(1500):
# @Hmm: sometimes wait() complains about QThread waiting on itself
self.log.debug("Thread \"{}\" didn't stop in time, exiting".format(thread))
return
except RuntimeError: # happens when thread has been deleted before we got to it
self.log.debug('Thread {} has been deleted already'.format(thread))
self.log.debug('Waiting for connections has stopped')
示例2: _create_worker
# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QThread [as 別名]
def _create_worker(self, method, *args, **kwargs):
"""Create a worker for this client to be run in a separate thread."""
# FIXME: this might be heavy...
thread = QThread()
worker = ClientWorker(method, args, kwargs)
worker.moveToThread(thread)
worker.sig_finished.connect(self._start)
worker.sig_finished.connect(thread.quit)
thread.started.connect(worker.start)
self._queue.append(thread)
self._threads.append(thread)
self._workers.append(worker)
self._start()
return worker
示例3: _create_worker
# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QThread [as 別名]
def _create_worker(self, method, *args, **kwargs):
"""Create a new worker instance."""
thread = QThread()
worker = RequestsDownloadWorker(method, args, kwargs)
worker.moveToThread(thread)
worker.sig_finished.connect(self._start)
self._sig_download_finished.connect(worker.sig_download_finished)
self._sig_download_progress.connect(worker.sig_download_progress)
worker.sig_finished.connect(thread.quit)
thread.started.connect(worker.start)
self._queue.append(thread)
self._threads.append(thread)
self._workers.append(worker)
self._start()
return worker