当前位置: 首页>>代码示例>>Python>>正文


Python QThreadPool.waitForDone方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QThreadPool.waitForDone方法的典型用法代码示例。如果您正苦于以下问题:Python QThreadPool.waitForDone方法的具体用法?Python QThreadPool.waitForDone怎么用?Python QThreadPool.waitForDone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QThreadPool的用法示例。


在下文中一共展示了QThreadPool.waitForDone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Tasks

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import waitForDone [as 别名]
class Tasks(QObject):
    def __init__(self, ar, process_result):
        super(Tasks, self).__init__()
        self.ar = ar
        self.process_result = process_result
        self.pool = QThreadPool()
        self.pool.setMaxThreadCount(10)

    # def process_result(self, rev):
    #     # print 'Receiving', rev
    #     self.ref.setText(rev)

    def start(self):
        self.factory = GenerWork(self.ar)

        self.factory.generateWorkers()
        workers = self.factory.get_workers()

        # print workers
        for worker in workers:
            worker.signals.result.connect(self.process_result)

            self.pool.start(worker)

        self.pool.waitForDone()
        return data

    def get_shell_data(self):
        return self.factory.get_shell_data()
开发者ID:sunsray,项目名称:syn_tool,代码行数:31,代码来源:StayRatioTask.py

示例2: start

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import waitForDone [as 别名]
    def start(self):
        self.idmap = {}
        self.entries = []

        pool = QThreadPool()
        pool.setMaxThreadCount(1)

        for label in LABELS:
            feed = Feed(label, self)
            pool.start(feed)
            imap = Imap(label, self)
            pool.start(imap)

        pool.waitForDone()
        self.done.emit()
开发者ID:gen2brain,项目名称:gmailcheck,代码行数:17,代码来源:gmailcheck.py

示例3: QFileWorker

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import waitForDone [as 别名]
class QFileWorker(object):

    def __init__(self, deletions, cls):
        """
        This class handles deletion of temporary file objects once processing
        has completed.

        It takes a reference to the class because we re-enable it's button
        because we disabled it during processing
        """

        self.deletions = deletions
        self.threadpool = QThreadPool()
        self.cls = cls
        self._start()

    def _start(self):
        deleter = QFileCleaner(self.deletions, self.cls)
        self.threadpool.start(deleter)
        self.threadpool.waitForDone()
开发者ID:AeroNotix,项目名称:pdftotif,代码行数:22,代码来源:mthreading.py

示例4: CatalogDialogTool

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import waitForDone [as 别名]

#.........这里部分代码省略.........
        """
        # can't run search during export
        if self.is_exporting():
            self.iface.messageBar().pushMessage("Error", "Cannot run search while export is running.", level=QgsMessageBar.CRITICAL)
        # can't run multiple search
        elif self.is_searching():
            self.iface.messageBar().pushMessage("Error", "Cannot run a new search while a search is running.", level=QgsMessageBar.CRITICAL)
        else:
            self.bbox_tool.reset()
            self.iface.mapCanvas().setMapTool(self.bbox_tool)

    def reset_button_clicked(self):
        """
        Resets filters.
        :return: None
        """
        self.reset()

    def export_button_clicked(self):
        """
        Validates and runs the export if validation successful
        :return: None
        """
        # can't run export during search
        if self.is_searching():
            self.iface.messageBar().pushMessage("Error", "Cannot run export while search is running.", level=QgsMessageBar.CRITICAL)
        # can't run multiple exports
        elif self.is_exporting():
            self.iface.messageBar().pushMessage("Error", "Cannot run a new export while a export is running.", level=QgsMessageBar.CRITICAL)
        else:
            self.export()

    def search(self, top, bottom, left, right):
        self.search_thread_pool.waitForDone(0)

        # validate credentials if they changed
        errors = []
        username, password, api_key, max_items_to_return = SettingsOps.get_settings()
        credentials = [username, password, api_key]
        if not self.previous_credentials or self.previous_credentials != credentials:
            SettingsOps.validate_stored_info(username, password, api_key, max_items_to_return, errors)
        self.previous_credentials = credentials

        # validate filters
        if not errors:
            self.filters.validate(errors)

        if errors:
            self.iface.messageBar().pushMessage("Error", "The following errors occurred: " + "<br />".join(errors), level=QgsMessageBar.CRITICAL)
        else:
            self.init_layers()

            self.dialog_ui.tab_widget.setCurrentIndex(RESULTS_TAB_INDEX)
            
            next_x_list = self.drange_list(float(left) + INCREMENTAL_INTERVAL, float(right), INCREMENTAL_INTERVAL)
            next_y_list = self.drange_list(float(bottom) + INCREMENTAL_INTERVAL, float(top), INCREMENTAL_INTERVAL)
            self.init_progress_bar(len(next_x_list) * len(next_y_list))

            self.model = CatalogTableModel(self.dialog_ui.table_view)
            self.dialog_ui.table_view.setModel(self.model)
            self.dialog_ui.table_view.selectionModel().selectionChanged.connect(self.selection_changed)

            if not self.query:
                self.query = GBDQuery(username=username, password=password, api_key=api_key)

            filters = self.filters.get_query_filters()
开发者ID:DigitalGlobe,项目名称:DGConnect,代码行数:70,代码来源:CatalogDialogTool.py

示例5: WorkHandler

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import waitForDone [as 别名]
class WorkHandler(object):
    """
    Class to handle threading of "work" (concretely this is just the evaluation of a function of the
     form func(*args, **kwargs).

     The process ID identifies (uniquely) each instance of a Worker; but the caller also defines
     an ID which is then used to identify the Worker through the API.
    """

    class WorkListener(with_metaclass(ABCMeta, object)):
        """
        This abstract base class defines methods which must be overriden and which
        handle responses to certain worker actions such as raised errors, or completion.
        """

        def __init__(self):
            pass

        @abstractmethod
        def on_processing_finished(self, result):
            pass

        @abstractmethod
        def on_processing_error(self, error):
            pass

    def __init__(self):
        self.thread_pool = None
        self._listener = {}
        self._worker = {}
        self.thread_pool = QThreadPool()

    def _add_listener(self, listener, process_id, id):
        if not isinstance(listener, WorkHandler.WorkListener):
            raise ValueError("The listener is not of type "
                             "WorkListener but rather {}".format(type(listener)))
        self._listener.update({process_id: {'id': id, 'listener': listener}})

    @pyqtSlot()
    def on_finished(self, process_id):
        if process_id not in self._worker:
            return
        result = self._worker.pop(process_id)['worker'].result
        self._listener.pop(process_id)['listener'].on_processing_finished(result)

    @pyqtSlot()
    def on_error(self, process_id, error):
        if process_id not in self._worker:
            return
        self._listener[process_id]['listener'].on_processing_error(error)

    def process(self, caller, func, id, *args, **kwargs):
        """
        Process a function call with arbitrary arguments on a new thread.

        :param caller: ??
        :param func: The function to be evaluated.
        :param id: An identifying integer for the task.
        :param args: args for func.
        :param kwargs: keyword args for func.
        """
        self.remove_already_processing(id)
        process_id = uuid.uuid4()
        # Add the caller
        self._add_listener(caller, process_id, id)

        finished_callback = functools.partial(self.on_finished, process_id)
        error_callback = functools.partial(self.on_error, process_id)

        worker = Worker(func, *args, **kwargs)
        worker.signals.finished.connect(finished_callback)
        worker.signals.error.connect(error_callback)

        self._worker.update({process_id: {'id': id, 'worker': worker}})

        self.thread_pool.start(self._worker[process_id]['worker'])

    def remove_already_processing(self, id):
        """
        Remove workers with ID
        :param id:
        """
        for key, process in list(self._listener.items()):
            if process['id'] == id:
                self._listener.pop(key)
                self._worker.pop(key)

    def wait_for_done(self):
        self.thread_pool.waitForDone()

    def __eq__(self, other):
        return self.__dict__ == other.__dict__

    def __ne__(self, other):
        return self.__dict__ != other.__dict__
开发者ID:samueljackson92,项目名称:mantid,代码行数:97,代码来源:work_handler.py


注:本文中的PyQt4.QtCore.QThreadPool.waitForDone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。