Пример #1
0
    async def test_coro(self, loop):
        async def foo():
            await asyncio.sleep(0)
            return 42

        bar = LazyCoroutine(foo)

        assert await bar == 42
Пример #2
0
    def basic_reject(self, delivery_tag, *, requeue=True) -> DrainResult:
        self.writer.write(
            pamqp.frame.marshal(
                spec.Basic.Reject(delivery_tag=delivery_tag, requeue=requeue),
                self.number,
            ), )

        return LazyCoroutine(self.connection.drain)
Пример #3
0
    def basic_ack(self, delivery_tag, multiple=False) -> DrainResult:
        self.writer.write(
            pamqp.frame.marshal(
                spec.Basic.Ack(delivery_tag=delivery_tag, multiple=multiple),
                self.number,
            ), )

        return LazyCoroutine(self.connection.drain)
Пример #4
0
    async def test_future(self, loop):
        def foo():
            f = loop.create_future()
            loop.call_soon(f.set_result, 42)
            return f

        bar = LazyCoroutine(foo)

        assert await bar == 42
Пример #5
0
    async def test_task(self, loop):
        def foo():
            async def inner():
                await asyncio.sleep(0)
                return 42

            return loop.create_task(inner())

        bar = LazyCoroutine(foo)

        assert await bar == 42
Пример #6
0
    def basic_nack(self,
                   delivery_tag: str = None,
                   multiple: bool = False,
                   requeue: bool = True) -> DrainResult:
        if not self.connection.basic_nack:
            raise exc.MethodNotImplemented

        self.writer.write(
            pamqp.frame.marshal(
                spec.Basic.Nack(delivery_tag=delivery_tag,
                                multiple=multiple,
                                requeue=requeue), self.number))

        return LazyCoroutine(self.connection.drain)