本文整理汇总了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