__init__.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:aiopubsub 作者: qntln 项目源码 文件源码
def add_listener(self, keys: Union[Key, Set[Key]], callback: ListenerCallback) -> None:
        '''
        Attach ``callback`` to one or more keys. If more than one key is provided, the callback will be
        reading all messages from one queue, and they are guaranteed to arrive in the same order they were published.

        :param keys: One key, or a set of keys.
        '''
        keys, sub_id = self._get_listener_subscription(keys, callback)
        for key in keys:
            self.subscribe(key, sub_id)

        async def consumer() -> None:
            key, msg = await self.consume(sub_id)
            callback(key, msg)

        loop = aiopubsub.loop.Loop(consumer, delay = None)
        loop.start()
        self._listeners[sub_id] = Listener(loop, keys)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号