Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from aiohttp import web
- def sync_fn(param1, param2):
- time.sleep(5)
- return 'Hello, world!'
- async def hello(request):
- with ThreadPoolExecutor(max_workers=1) as executor:
- future = executor.submit(sync_fn, param1, param2)
- result = future.result()
- return web.Response(text=result)
- app = web.Application()
- app.router.add_route('GET', '/', hello)
- web.run_app(app)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement