Proper errors when server cannot bind
This commit is contained in:
parent
2cfce77328
commit
33f712ef9b
|
@ -151,7 +151,14 @@ def serve(host, port, request_handler, after_start=None, before_stop=None, debug
|
||||||
request_timeout=request_timeout,
|
request_timeout=request_timeout,
|
||||||
request_max_size=request_max_size,
|
request_max_size=request_max_size,
|
||||||
), host, port)
|
), host, port)
|
||||||
|
try:
|
||||||
http_server = loop.run_until_complete(server_coroutine)
|
http_server = loop.run_until_complete(server_coroutine)
|
||||||
|
except OSError as e:
|
||||||
|
log.error("Unable to start server: {}".format(e))
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
log.exception("Unable to start server")
|
||||||
|
return
|
||||||
|
|
||||||
# Run the on_start function if provided
|
# Run the on_start function if provided
|
||||||
if after_start:
|
if after_start:
|
||||||
|
|
|
@ -18,4 +18,4 @@ async def test(request):
|
||||||
async def test(request):
|
async def test(request):
|
||||||
return json({ "test": True, "files": request.files, "fields": request.form })
|
return json({ "test": True, "files": request.files, "fields": request.form })
|
||||||
|
|
||||||
app.run(host="0.0.0.0", port=sys.argv[1], debug=True)
|
app.run(host="0.0.0.0", port=sys.argv[1])
|
Loading…
Reference in New Issue
Block a user