Skip to content

Instantly share code, notes, and snippets.

@palazzem
Created October 5, 2017 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palazzem/a7a53c06e9e270c9f71505de4752c8d5 to your computer and use it in GitHub Desktop.
Save palazzem/a7a53c06e9e270c9f71505de4752c8d5 to your computer and use it in GitHub Desktop.
pygotham_talk_handler.py
class Handler(object):
async def handle_request(self, request):
# set the current context
ctx = {}
set_current_context(ctx)
ctx['username'] = request.get('username', 'Anonymous')
result = await retrieve_user_data()
return result
async def retrieve_user_data(self):
# do a long call
await asyncio.sleep(2)
ctx = get_current_context()
return ctx['username']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment