Exemple #1
0
 async def _call_trio_ctx():
     self.did_it = 0
     async with trio_as_aio(TrioContext(self)) as ctx:
         assert ctx.parent is self
         assert self.did_it == 2
         self.did_it = 3
     assert self.did_it == 4
Exemple #2
0
 async def run_asyncio_trio_iter(self, loop):
     sth = SomeThing(loop)
     n = 0
     if sys.version_info >= (3, 7):
         assert sniffio.current_async_library() == "asyncio"
     async for x in trio_as_aio(sth.iter_trio()):
         n += 1
         assert x == n
     assert n == 2
     assert sth.flag == 1
Exemple #3
0
async def process_rabbit(receive_channel, refresh_timeout, rabbit_user,
                         rabbit_pass, rabbit_host, rabbit_port):
    async with rabbit_connection(rabbit_user, rabbit_pass, rabbit_host,
                                 rabbit_port) as conn:
        async for value in trio_as_aio(receive_channel):
            logger.debug(f"Sent {value}")
            await conn.basic_publish(payload=value,
                                     exchange_name='',
                                     routing_key='buses')
            await asyncio.sleep(refresh_timeout)
Exemple #4
0
 async def run_asyncio_trio_ctx(self, loop):
     sth = SomeThing(loop)
     async with trio_as_aio(sth.ctx_trio()):
         assert sth.flag == 1
     assert sth.flag == 3