当前位置: 首页>>代码示例>>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;未经允许,请勿转载。