Skip to content

Instantly share code, notes, and snippets.

@njsmith
Created March 11, 2017 15:51
Show Gist options
  • Select an option

  • Save njsmith/a394fce6ab07d4135565b37c903bea93 to your computer and use it in GitHub Desktop.

Select an option

Save njsmith/a394fce6ab07d4135565b37c903bea93 to your computer and use it in GitHub Desktop.
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