How to use the aiorun.shutdown_waits_for function in aiorun

To help you get started, we’ve selected a few aiorun examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cjrh / aiorun / tests / test_posix.py View on Github external
async def main():
        # Note that we don't need a loop variable anywhere!
        asyncio.ensure_future(shutdown_waits_for(corofn()))
github cjrh / aiorun / tests / test_posix.py View on Github external
async def main():
        try:
            # This one is fast enough to finish
            out = await shutdown_waits_for(corofn(sleep=0.01))
            assert out is True

            # This one is going to last longer than the shutdown
            # but we can't get anything back out if that happens.
            await shutdown_waits_for(corofn(sleep=0.03))
            # main() gets cancelled here
            await asyncio.sleep(2)  # pragma: no cover.
            # This append won't happen
            items.append(True)  # pragma: no cover.
        except asyncio.CancelledError:
            print("main got cancelled")
            raise
github cjrh / aiorun / tests / test_posix.py View on Github external
async def main():
        shutdown_waits_for(corofn())  # <-- Look Ma! No awaits!
github cjrh / aiorun / tests / test_posix.py View on Github external
async def main():
        loop = asyncio.get_event_loop()
        loop.create_task(shutdown_waits_for(corofn()))
github cjrh / aiorun / tests / test_posix.py View on Github external
async def main():
        loop = asyncio.get_event_loop()
        coro = corofn(sleep=0.2)
        loop.call_later(0.1, direct_cancel)
        with pytest.raises(asyncio.CancelledError):
            await shutdown_waits_for(coro)

aiorun

Boilerplate for asyncio applications

Apache-2.0
Latest version published 5 months ago

Package Health Score

71 / 100
Full package analysis