Python gevent.queue 模块,put() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用gevent.queue.put()

项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
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)
项目:deb-kazoo    作者:openstack    | 项目源码 | 文件源码
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)
项目:vAdvisor    作者:kubevirt    | 项目源码 | 文件源码
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
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
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))
项目:iris    作者:linkedin    | 项目源码 | 文件源码
def init_queue_with_item(queue, item=None):
    # drain out queue
    while queue.qsize() > 0:
        queue.get()
    if item:
        queue.put(item)
项目:deb-kazoo    作者:openstack    | 项目源码 | 文件源码
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))