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


Python queue.Full方法代碼示例

本文整理匯總了Python中six.moves.queue.Full方法的典型用法代碼示例。如果您正苦於以下問題:Python queue.Full方法的具體用法?Python queue.Full怎麽用?Python queue.Full使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在six.moves.queue的用法示例。


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

示例1: test_30_full

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def test_30_full(self):
        self.assertEqual(self.q1.qsize(), 0)
        self.assertEqual(self.q2.qsize(), 0)
        for i in range(2):
            self.q1.put_nowait('TEST_DATA%d' % i)
        for i in range(3):
            self.q2.put('TEST_DATA%d' % i)

        print(self.q1.__dict__)
        print(self.q1.qsize())
        with self.assertRaises(Queue.Full):
            self.q1.put_nowait('TEST_DATA6')
        print(self.q1.__dict__)
        print(self.q1.qsize())
        with self.assertRaises(Queue.Full):
            self.q1.put('TEST_DATA6', timeout=0.01) 
開發者ID:binux,項目名稱:pyspider,代碼行數:18,代碼來源:test_message_queue.py

示例2: put

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def put(self, obj, block=True, timeout=None):
        if not block:
            return self.put_nowait()

        start_time = time.time()
        while True:
            try:
                return self.put_nowait(obj)
            except BaseQueue.Full:
                if timeout:
                    lasted = time.time() - start_time
                    if timeout > lasted:
                        time.sleep(min(self.max_timeout, timeout - lasted))
                    else:
                        raise
                else:
                    time.sleep(self.max_timeout) 
開發者ID:binux,項目名稱:pyspider,代碼行數:19,代碼來源:rabbitmq.py

示例3: put

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def put(self, obj, block=True, timeout=None):
        if not block:
            return self.put_nowait(obj)

        start_time = time.time()
        while True:
            try:
                return self.put_nowait(obj)
            except BaseQueue.Full:
                if timeout:
                    lasted = time.time() - start_time
                    if timeout > lasted:
                        time.sleep(min(self.max_timeout, timeout - lasted))
                    else:
                        raise
                else:
                    time.sleep(self.max_timeout) 
開發者ID:binux,項目名稱:pyspider,代碼行數:19,代碼來源:kombu_queue.py

示例4: put

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def put(self, obj, block=True, timeout=None):
        if not block:
            return self.put_nowait(obj)

        start_time = time.time()
        while True:
            try:
                return self.put_nowait(obj)
            except self.Full:
                if timeout:
                    lasted = time.time() - start_time
                    if timeout > lasted:
                        time.sleep(min(self.max_timeout, timeout - lasted))
                    else:
                        raise
                else:
                    time.sleep(self.max_timeout) 
開發者ID:binux,項目名稱:pyspider,代碼行數:19,代碼來源:redis_queue.py

示例5: process

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def process(self, user_event):
        """ Method to process the user_event by putting it in event_queue.

    Args:
      user_event: UserEvent Instance.
    """
        if not isinstance(user_event, UserEvent):
            self.logger.error('Provided event is in an invalid format.')
            return

        self.logger.debug(
            'Received event of type {} for user {}.'.format(type(user_event).__name__, user_event.user_id)
        )

        try:
            self.event_queue.put_nowait(user_event)
        except queue.Full:
            self.logger.debug(
                'Payload not accepted by the queue. Current size: {}'.format(str(self.event_queue.qsize()))
            ) 
開發者ID:optimizely,項目名稱:python-sdk,代碼行數:22,代碼來源:event_processor.py

示例6: run

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def run(self):
        try:
            self._entrypoint()
        except StopIteration:
            logger.debug(
                ("Thread runner raised StopIteration. Interperting it as a "
                 "signal to terminate the thread without error."))
        except Exception as e:
            logger.exception("Runner Thread raised error.")
            try:
                # report the error but avoid indefinite blocking which would
                # prevent the exception from being propagated in the unlikely
                # case that something went terribly wrong
                err_tb_str = traceback.format_exc()
                self._error_queue.put(
                    err_tb_str, block=True, timeout=ERROR_REPORT_TIMEOUT)
            except queue.Full:
                logger.critical(
                    ("Runner Thread was unable to report error to main "
                     "function runner thread. This means a previous error "
                     "was not processed. This should never happen."))
            raise e 
開發者ID:ray-project,項目名稱:ray,代碼行數:24,代碼來源:function_runner.py

示例7: queue_put_stoppable

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def queue_put_stoppable(self, q, obj):
        """ Put obj to queue, but will give up when the thread is stopped"""
        while not self.stopped():
            try:
                q.put(obj, timeout=5)
                break
            except queue.Full:
                pass 
開發者ID:tensorpack,項目名稱:dataflow,代碼行數:10,代碼來源:concurrency.py

示例8: put_nowait

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def put_nowait(self, obj):
        if self.lazy_limit and self.qsize_diff < self.qsize_diff_limit:
            pass
        elif self.full():
            raise BaseQueue.Full
        else:
            self.qsize_diff = 0
        with self.lock:
            self.qsize_diff += 1
            return self.channel.basic_publish("", self.name, umsgpack.packb(obj)) 
開發者ID:binux,項目名稱:pyspider,代碼行數:12,代碼來源:rabbitmq.py

示例9: put_nowait

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def put_nowait(self, obj):
        if self.lazy_limit and self.qsize_diff < self.qsize_diff_limit:
            pass
        elif self.full():
            raise BaseQueue.Full
        else:
            self.qsize_diff = 0
        return self.queue.put(obj) 
開發者ID:binux,項目名稱:pyspider,代碼行數:10,代碼來源:kombu_queue.py

示例10: put_nowait

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def put_nowait(self, obj):
        if self.lazy_limit and self.last_qsize < self.maxsize:
            pass
        elif self.full():
            raise self.Full
        self.last_qsize = self.redis.rpush(self.name, umsgpack.packb(obj))
        return True 
開發者ID:binux,項目名稱:pyspider,代碼行數:9,代碼來源:redis_queue.py

示例11: send_task

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def send_task(self, task, force=True):
        '''
        dispatch task to fetcher

        out queue may have size limit to prevent block, a send_buffer is used
        '''
        try:
            self.out_queue.put_nowait(task)
        except Queue.Full:
            if force:
                self._send_buffer.appendleft(task)
            else:
                raise 
開發者ID:binux,項目名稱:pyspider,代碼行數:15,代碼來源:scheduler.py

示例12: learn

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def learn(self, batch_data):
        """Update upon a batch and send the td_errors to memories if needed

        Returns:
            extra_results (dict): contains the fields computed during an update.
        """
        buffer_id = batch_data.pop("buffer_id", 0)
        extra_results = super(ApexAgent, self).learn(
            batch_data, is_chief=self.distributed_handler.is_chief)
        extra_results["buffer_id"] = buffer_id

        if self.config.get("prioritized_replay",
                           False) and not self._learner2mem_q.full():
            try:
                self._learner2mem_q.put(
                    [
                        int(buffer_id), batch_data["indexes"],
                        extra_results["td_error"]
                    ],
                    timeout=30)
            except Queue.Full as e:
                logger.warn(
                    "learner2mem thread has not sent even one batch for 30 seconds. It is necessary to increase the number of memory hosts."
                )
            finally:
                pass

        return extra_results 
開發者ID:alibaba,項目名稱:EasyRL,代碼行數:30,代碼來源:apex_agent.py

示例13: coordinated_put

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def coordinated_put(coordinator, queue, element):
    while not coordinator.should_stop():
        try:
            queue.put(element, block=True, timeout=1.0)
            return
        except Queue.Full:
            continue
    raise Exception('Coordinator stopped during put()') 
開發者ID:yihui-he,項目名稱:KL-Loss,代碼行數:10,代碼來源:coordinator.py

示例14: queue_put_stoppable

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def queue_put_stoppable(self, q, obj):
        """ put obj to queue, but will give up if the thread is stopped"""
        while not self.stopped():
            try:
                q.put(obj, timeout=5)
                break
            except queue.Full:
                pass 
開發者ID:anonymous-author1,項目名稱:DDRL,代碼行數:10,代碼來源:concurrency.py

示例15: _stop_aware_put

# 需要導入模塊: from six.moves import queue [as 別名]
# 或者: from six.moves.queue import Full [as 別名]
def _stop_aware_put(self, data):
        """This method is called to write the results to the results queue. We use ``put`` in a non-blocking way so we
        can gracefully terminate the worker thread without being stuck on :func:`Queue.put`.

        The method raises :class:`.WorkerTerminationRequested` exception that should be passed through all the way up to
        :func:`WorkerThread.run` which will gracefully terminate main worker loop."""
        while True:
            try:
                self._results_queue.put(data, block=True, timeout=IO_TIMEOUT_INTERVAL_S)
                return
            except queue.Full:
                pass

            if self._stop_event.is_set():
                raise WorkerTerminationRequested() 
開發者ID:uber,項目名稱:petastorm,代碼行數:17,代碼來源:thread_pool.py


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