Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. from aiohttp import web
  2.  
  3. def sync_fn(param1, param2):
  4.     time.sleep(5)
  5.     return 'Hello, world!'
  6.  
  7. async def hello(request):
  8.     with ThreadPoolExecutor(max_workers=1) as executor:
  9.         future = executor.submit(sync_fn, param1, param2)
  10.         result = future.result()
  11.     return web.Response(text=result)
  12.  
  13. app = web.Application()
  14. app.router.add_route('GET', '/', hello)
  15.  
  16. web.run_app(app)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement