mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-16 05:18:56 +00:00
Backport: Fixes RuntimeError: Event loop is closed.
This commit is contained in:
parent
439e0df058
commit
19425b1e9c
@ -85,7 +85,8 @@ class Server:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if self._handler:
|
if self._handler:
|
||||||
yield from self._handler.finish_connections()
|
yield from self._handler.finish_connections(1.0)
|
||||||
|
self._handler = None
|
||||||
|
|
||||||
for module in MODULES:
|
for module in MODULES:
|
||||||
log.debug("Unloading module {}".format(module.__name__))
|
log.debug("Unloading module {}".format(module.__name__))
|
||||||
@ -175,6 +176,10 @@ class Server:
|
|||||||
yield from embed(globals(), locals(), return_asyncio_coroutine=True, patch_stdout=True)
|
yield from embed(globals(), locals(), return_asyncio_coroutine=True, patch_stdout=True)
|
||||||
|
|
||||||
def _exit_handling(self):
|
def _exit_handling(self):
|
||||||
|
"""
|
||||||
|
Makes sure the asyncio loop is closed.
|
||||||
|
"""
|
||||||
|
|
||||||
def close_asyncio_loop():
|
def close_asyncio_loop():
|
||||||
loop = None
|
loop = None
|
||||||
try:
|
try:
|
||||||
@ -226,7 +231,8 @@ class Server:
|
|||||||
|
|
||||||
log.info("Starting server on {}:{}".format(self._host, self._port))
|
log.info("Starting server on {}:{}".format(self._host, self._port))
|
||||||
self._handler = app.make_handler(handler=RequestHandler)
|
self._handler = app.make_handler(handler=RequestHandler)
|
||||||
self._loop.run_until_complete(self._run_application(self._handler, ssl_context))
|
server = self._run_application(self._handler, ssl_context)
|
||||||
|
self._loop.run_until_complete(server)
|
||||||
self._signal_handling()
|
self._signal_handling()
|
||||||
|
|
||||||
self._exit_handling()
|
self._exit_handling()
|
||||||
@ -245,3 +251,8 @@ class Server:
|
|||||||
# on Windows when the process gets the SIGBREAK signal
|
# on Windows when the process gets the SIGBREAK signal
|
||||||
# TypeError: async() takes 1 positional argument but 3 were given
|
# TypeError: async() takes 1 positional argument but 3 were given
|
||||||
log.warning("TypeError exception in the loop {}".format(e))
|
log.warning("TypeError exception in the loop {}".format(e))
|
||||||
|
finally:
|
||||||
|
if self._handler:
|
||||||
|
self._loop.run_until_complete(self._handler.finish_connections(1.0))
|
||||||
|
server.close()
|
||||||
|
self._loop.run_until_complete(app.finish())
|
||||||
|
Loading…
Reference in New Issue
Block a user