python类put()的实例源码

gevent.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def stop(self):
        """Stop the greenlet workers and empty all queues."""
        with self._state_change:
            if not self._running:
                return

            self._running = False

            for queue in (self.callback_queue,):
                queue.put(_STOP)

            while self._workers:
                worker = self._workers.pop()
                worker.join()

            # Clear the queues
            self.callback_queue = Queue()  # pragma: nocover

            python2atexit.unregister(self.stop)
gevent.py 文件源码 项目:deb-kazoo 作者: openstack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def stop(self):
        """Stop the greenlet workers and empty all queues."""
        with self._state_change:
            if not self._running:
                return

            self._running = False

            for queue in (self.callback_queue,):
                queue.put(_STOP)

            while self._workers:
                worker = self._workers.pop()
                worker.join()

            # Clear the queues
            self.callback_queue = Queue()  # pragma: nocover

            python2atexit.unregister(self.stop)
test_events.py 文件源码 项目:vAdvisor 作者: kubevirt 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _app():
    class Broker:

        def subscribe(self, subscriber):
            for idx, _ in enumerate(LIFECYCLE_EVENTS):
                subscriber.put(event(idx))
            subscriber.put(StopIteration)

        def unsubscribe(self, queue):
            queue.put(StopIteration)

    app = vadvisor.app.rest.app
    broker = Broker()
    app.eventBroker = broker
    app.eventStore = InMemoryStore()

    q = queue.Queue()
    broker.subscribe(q)
    for element in q:
        app.eventStore.put(element)

    return app
gevent.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def dispatch_callback(self, callback):
        """Dispatch to the callback object

        The callback is put on separate queues to run depending on the
        type as documented for the :class:`SequentialGeventHandler`.

        """
        self.callback_queue.put(lambda: callback.func(*callback.args))
test_sender.py 文件源码 项目:iris 作者: linkedin 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def init_queue_with_item(queue, item=None):
    # drain out queue
    while queue.qsize() > 0:
        queue.get()
    if item:
        queue.put(item)
gevent.py 文件源码 项目:deb-kazoo 作者: openstack 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def dispatch_callback(self, callback):
        """Dispatch to the callback object

        The callback is put on separate queues to run depending on the
        type as documented for the :class:`SequentialGeventHandler`.

        """
        self.callback_queue.put(lambda: callback.func(*callback.args))


问题


面经


文章

微信
公众号

扫码关注公众号