Work around a bug in uasyncio's create_server() function

This commit is contained in:
Miguel Grinberg
2021-06-06 20:05:12 +01:00
parent 1a8db51cb3
commit 46963ba464

View File

@@ -162,7 +162,14 @@ class Microdot(BaseMicrodot):
host=host, port=port)) host=host, port=port))
self.server = await asyncio.start_server(serve, host, 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): def run(self, host='0.0.0.0', port=5000, debug=False):
"""Start the web server. This function does not normally return, as """Start the web server. This function does not normally return, as