Issue
In some test code I simulate a request handler coroutine that never returns a response. Below works by calling sleep
with a sufficiently large value, but a better choice would be something like await asyncio.sleep_forever()
. Is there anything built into python asyncio that can do this?
async def lagging_request_handler(request):
await asyncio.sleep(10000)
Solution
You can await asyncio.Future()
to make it run forever. It’s used in the websockets docs to serve forever: https://websockets.readthedocs.io/en/stable/
Answered By - HiPeople
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.