Created
March 11, 2017 15:51
-
-
Save njsmith/a394fce6ab07d4135565b37c903bea93 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import trio | |
| class PromiseLikeThing: | |
| def __init__(self): | |
| self._result = None | |
| self._event = trio.Event() | |
| async def get(self): | |
| await self._event.wait() | |
| return self._result.unwrap() | |
| def set_result(self, result): | |
| self._result = result | |
| self._event.set() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment