Last active
May 17, 2019 03:13
-
-
Save njsmith/74adef4a863b335eabdbb02569a9da30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gitter.im/python-trio/general?at=5cddee9a6366992a94ce41c5 | |
@asynccontextmanager | |
async def generalized_move_on_after(): | |
async with trio.open_nursery() as nursery: | |
async def arbitrary_event(): | |
await wait_for_some_arbitrary_event() | |
nursery.cancel_scope.cancel() | |
nursery.start_soon(arbitrary_event) | |
yield nursery.cancel_scope | |
nursery.cancel_scope.cancel() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment