serve
closes the loop only when it created its own loop.
When you were running multiple applications using asyncio, sanic must be closed as the latest order because it closes the loop. The patch limits the behavior only when sanic created its own loop by argument `loop=None`.
This commit is contained in:
parent
1f89b15792
commit
e5196a49ff
|
@ -290,8 +290,10 @@ def serve(host, port, request_handler, error_handler, before_start=None,
|
||||||
:param protocol: Subclass of asyncio protocol class
|
:param protocol: Subclass of asyncio protocol class
|
||||||
:return: Nothing
|
:return: Nothing
|
||||||
"""
|
"""
|
||||||
loop = loop or async_loop.new_event_loop()
|
create_new_loop = loop is None
|
||||||
asyncio.set_event_loop(loop)
|
if create_new_loop:
|
||||||
|
loop = async_loop.new_event_loop()
|
||||||
|
asyncio.set_event_loop(loop)
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
loop.set_debug(debug)
|
loop.set_debug(debug)
|
||||||
|
@ -360,4 +362,5 @@ def serve(host, port, request_handler, error_handler, before_start=None,
|
||||||
|
|
||||||
trigger_events(after_stop, loop)
|
trigger_events(after_stop, loop)
|
||||||
|
|
||||||
loop.close()
|
if create_new_loop:
|
||||||
|
loop.close()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user