Skip to content

Commit

Permalink
Work around a bug in uasyncio's create_server() function
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Jun 6, 2021
1 parent 1a8db51 commit 46963ba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/microdot_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@ async def aclose(self):
host=host, port=port))

self.server = await asyncio.start_server(serve, host, port)
await self.server.wait_closed()
while True:
try:
await self.server.wait_closed()
break
except AttributeError: # pragma: no cover
# the task hasn't been initialized in the server object yet
# wait a bit and try again
await asyncio.sleep(0.1)

def run(self, host='0.0.0.0', port=5000, debug=False):
"""Start the web server. This function does not normally return, as
Expand Down

0 comments on commit 46963ba

Please sign in to comment.