Python qtpy.QtCore.QThread() Examples

The following are 3 code examples of qtpy.QtCore.QThread(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module qtpy.QtCore , or try the search function .
Example #1
Source File: listener.py    From cutelog with MIT License 5 votes vote down vote up
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') 
Example #2
Source File: client_api.py    From conda-manager with MIT License 5 votes vote down vote up
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 
Example #3
Source File: download_api.py    From conda-manager with MIT License 5 votes vote down vote up
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