當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QThreadPool類代碼示例

本文整理匯總了Python中PyQt4.QtCore.QThreadPool的典型用法代碼示例。如果您正苦於以下問題:Python QThreadPool類的具體用法?Python QThreadPool怎麽用?Python QThreadPool使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QThreadPool類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, iface, dialog_ui, bbox_tool):
        """
        Constructor for the dialog tool
        :param iface: The QGIS Interface
        :param dialog_ui: The dialog GUI
        :param bbox_tool The bounding box tool
        :return: dialog tool
        """
        QObject.__init__(self, None)
        self.iface = iface
        self.dialog_ui = dialog_ui
        self.bbox_tool = bbox_tool

        self.progress_bar = None
        self.progress_message_bar = None
        self.progress_message_bar_widget = None
        self.search_thread_pool = QThreadPool()
        self.search_lock = Lock()
        self.export_thread_pool = QThreadPool()
        self.export_lock = Lock()
        self.query = None
        self.previous_credentials = None
        self.export_file = None
        self.footprint_layer = None

        self.filters = CatalogFilters(self.dialog_ui)

        self.dialog_ui.aoi_button.clicked.connect(self.aoi_button_clicked)
        self.dialog_ui.reset_button.clicked.connect(self.reset_button_clicked)
        self.dialog_ui.export_button.clicked.connect(self.export_button_clicked)
        self.bbox_tool.released.connect(self.search)
        self.model = None
開發者ID:DigitalGlobe,項目名稱:DGConnect,代碼行數:32,代碼來源:CatalogDialogTool.py

示例2: on_send_status_clicked

 def on_send_status_clicked(self):
     status = self.ui.status.toPlainText().__str__()
     self.ui.status.clear()
     self.ui.status.setReadOnly(True)
     sender = SenderCommand(self.client, status)
     sender.posted.connect(self.status_posted)
     command_processor = CommandProcessor(sender)
     QThreadPool.globalInstance().start(command_processor)
     
開發者ID:kgusakov,項目名稱:kwitter,代碼行數:8,代碼來源:mainwindow.py

示例3: run_worker

    def run_worker(self, task, callback):
        """Runs a task in another thread.

        The `task` must be an object that implements a `run()`
        method. Completion is notified to the given `callback` function.

        """
        worker = Worker(task)
        worker.finished.connect(callback)
        QThreadPool.globalInstance().start(worker)
開發者ID:jfisteus,項目名稱:eyegrade,代碼行數:10,代碼來源:gui.py

示例4: process

    def process(self, caller, func, *args, **kwargs):
        # Add the caller
        self._add_listener(caller)

        # Generate worker
        self._worker = Worker(func, *args, **kwargs)
        self._worker.signals.finished.connect(self.on_finished)
        self._worker.signals.error.connect(self.on_error)

        QThreadPool.globalInstance().start(self._worker)
開發者ID:DanNixon,項目名稱:mantid,代碼行數:10,代碼來源:work_handler.py

示例5: query

 def query(self, key):
     """Emit query."""
     collect = Collect(
         list(map(lambda a: a.engine, filter(Group.selected, self.output_areas))),
         lambda r: self.record(key, r)
         )
     QThreadPool.globalInstance().start(collect)
     #for engine in self.engines:
         #QThreadPool.globalInstance().start(
                 #Runnable(lambda: engine.query(key), args=(object,)))
     async_actions(map(lambda e: partial(e.query, key), self.engines))
開發者ID:Answeror,項目名稱:memoit,代碼行數:11,代碼來源:gui.py

示例6: test_that_process_states_emits_row_processed_signal_after_each_row

    def test_that_process_states_emits_row_processed_signal_after_each_row(self):
        self.batch_process_runner.row_processed_signal = mock.MagicMock()
        self.batch_process_runner.row_failed_signal = mock.MagicMock()
        self.batch_process_runner.process_states(self.states, False, OutputMode.Both, False, '')
        QThreadPool.globalInstance().waitForDone()

        self.assertEqual(self.batch_process_runner.row_processed_signal.emit.call_count, 3)
        self.batch_process_runner.row_processed_signal.emit.assert_any_call(0, [], [])
        self.batch_process_runner.row_processed_signal.emit.assert_any_call(1, [], [])
        self.batch_process_runner.row_processed_signal.emit.assert_any_call(2, [], [])
        self.assertEqual(self.batch_process_runner.row_failed_signal.emit.call_count, 0)
開發者ID:samueljackson92,項目名稱:mantid,代碼行數:11,代碼來源:batch_process_runner_test.py

示例7: omap

def omap(fkt, par):
    """
    :type fkt: ()->
    :type par: list
    :rtype: list
    """
    # Die Anzahl der Prozesse ist ohne Aufwand auf einen idealen Wert beschränkt
    pool = QThreadPool()
    erg = [None] * len(par)
    for p in par:
        pool.start(QRunnable(fkt, p))
開發者ID:lustra,項目名稱:BE-ESM-Analysis,代碼行數:11,代碼來源:Pool.py

示例8: test_that_load_workspaces_emits_row_processed_signal_after_each_row

    def test_that_load_workspaces_emits_row_processed_signal_after_each_row(self):
        self.batch_process_runner.row_processed_signal = mock.MagicMock()
        self.batch_process_runner.row_failed_signal = mock.MagicMock()

        self.batch_process_runner.load_workspaces(self.states)
        QThreadPool.globalInstance().waitForDone()

        self.assertEqual(self.batch_process_runner.row_processed_signal.emit.call_count, 3)
        self.batch_process_runner.row_processed_signal.emit.assert_any_call(0, [], [])
        self.batch_process_runner.row_processed_signal.emit.assert_any_call(1, [], [])
        self.batch_process_runner.row_processed_signal.emit.assert_any_call(2, [], [])
        self.assertEqual(self.batch_process_runner.row_failed_signal.emit.call_count, 0)
開發者ID:samueljackson92,項目名稱:mantid,代碼行數:12,代碼來源:batch_process_runner_test.py

示例9: QWorker

class QWorker(QObject):

    """
    Starts the QRunnable in a QThreadPool,  inherits QObject because
    we need to connect signals from the objects we are creating to
    the functions that update the UI
    """

    def __init__(self):

        """
        This class creates new instances of QRunner, which is the class
        that directly interfaces with the external executable

        We need to create the QRunner/QWorker routine because a QRunnable
        does not inherit from QObject and therefore does not have access
        to the signal/slot mechanisms that we need in order to receive when
        things get done.

        QWorker inherits from QObject, so we need to directly call QObjects
        constructor to initialize the underlying C++ object, super() does not
        allow for this (seemingly) so we need to call it directly.
        """

        # init QObject
        QObject.__init__(self)
        # Our own threadpool, for adding QRunners
        self.threadpool = QThreadPool()
        self.jobs = []

    def create_job(self, ifname, ofname, cls):

        """
        This method takes three arguments:

        ifname is the input file name of the file to be converted
        ofname is a string which is to be the output of the filename
        cls is a reference to the calling class, so that we can connect
        a signal to a slot.
        """

        # Create the QRunner object and pass it filenames
        runner = QRunner(ifname, ofname, cls)

        # using our own connect method inherited from QObject
        # connect the QRunner created before and use it's QObject
        # to connect a signal to the slot
        self.connect(runner.q_object, SIGNAL(
                                         "finished()"), cls.update_progress_bar)

        # ask our threadpool to run the task
        self.threadpool.start(runner)
開發者ID:AeroNotix,項目名稱:pdftotif,代碼行數:52,代碼來源:mthreading.py

示例10: record

 def record(self, key, responses):
     """Record in background."""
     if not self.recorder is None:
         runnable = Runnable(lambda: self.recorder.add(
                 #word=s.word,
                 #pron=s.phonetic_symbol,
                 #trans='\n'.join(s.custom_translations),
                 #time=datetime.now()
                 key=key,
                 responses=responses
                 ))
         runnable.finished.connect(self.recorded)
         QThreadPool.globalInstance().start(runnable)
開發者ID:Answeror,項目名稱:memoit,代碼行數:13,代碼來源:gui.py

示例11: push_to_website

def push_to_website(payload):
    time = payload[SENSOR_TIMESTAMP]["val"]
    for key in payload:
        category = payload[key]["cat"]
        value = payload[key]["val"]

        if category == CAT_NONE:
            continue

        api = WebsiteAPI()
        api.set_password(WEB_PASSWORD)
        api.set_host(WEB_HOST)
        api.set_data(category, key, value, time)
        QThreadPool.globalInstance().start(api)
開發者ID:andrei-volkau,項目名稱:ground_station,代碼行數:14,代碼來源:push_to_website.py

示例12: __init__

    def __init__(self, func=None, args=(), kwargs={}, thread=None,
                 threadPool=None, parent=None):
        QObject.__init__(self, parent)
        self.func = func
        self._args = args
        self._kwargs = kwargs
        self.threadPool = None

        self._connected = True
        self._cancelRequested = False
        self._started = False
        self._cancelled = False

        if thread is not None:
            self.moveToThread(thread)
        else:
            if threadPool is None:
                threadPool = QThreadPool.globalInstance()
            self.threadPool = threadPool
            self._runnable = _RunnableAsyncCall(self)
            self.threadPool.start(self._runnable)
            self._connected = False
            return

        self.connect(self, SIGNAL("_async_start()"), self.execute,
                     Qt.QueuedConnection)
開發者ID:pauloortins,項目名稱:Computer-Vision-Classes---UFBA,代碼行數:26,代碼來源:OWConcurrent.py

示例13: __init__

 def __init__(self, control_system):
     """Make a instance of the ReaderAndWriterThread class.
     Args:
         protocol (SerialProtocol): It is a instance of a communication protocol.
     """
     QThread.__init__(self, control_system)
     self.writer_thread = QThreadPool(self)
     self.writer_thread.setMaxThreadCount(1)
開發者ID:andrei-volkau,項目名稱:ground_station,代碼行數:8,代碼來源:KISS_Thread.py

示例14: __init__

 def __init__(self, parent=None, threadPool=None):
     QObject.__init__(self, parent)
     if threadPool is None:
         threadPool = QThreadPool.globalInstance()
     self._threadPool = threadPool
     self._depot_thread = None
     self._futures = []
     self._shutdown = False
     self._state_lock = threading.Lock()
開發者ID:675801717,項目名稱:orange3,代碼行數:9,代碼來源:concurrent.py

示例15: start

    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,代碼行數:15,代碼來源:gmailcheck.py


注:本文中的PyQt4.QtCore.QThreadPool類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。