2013-10-30 23:58:17 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2015-01-14 02:05:26 +02:00
|
|
|
# Copyright (C) 2015 GNS3 Technologies Inc.
|
2013-10-30 23:58:17 +02:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2013-12-06 06:39:27 +02:00
|
|
|
"""
|
2014-03-11 23:45:04 +02:00
|
|
|
Set up and run the server.
|
2013-12-06 06:39:27 +02:00
|
|
|
"""
|
|
|
|
|
2013-12-05 09:21:06 +02:00
|
|
|
import os
|
2015-01-14 02:05:26 +02:00
|
|
|
import sys
|
2013-12-07 02:52:16 +02:00
|
|
|
import signal
|
2015-01-14 02:05:26 +02:00
|
|
|
import asyncio
|
|
|
|
import aiohttp
|
2016-05-17 13:39:23 +03:00
|
|
|
import aiohttp_cors
|
2015-01-14 02:05:26 +02:00
|
|
|
import functools
|
|
|
|
import time
|
2015-05-05 12:33:47 +03:00
|
|
|
import atexit
|
2018-10-16 11:56:06 +03:00
|
|
|
import weakref
|
2014-04-11 04:42:26 +03:00
|
|
|
|
2018-09-07 10:34:17 +03:00
|
|
|
# Import encoding now, to avoid implicit import later.
|
|
|
|
# Implicit import within threads may cause LookupError when standard library is in a ZIP
|
|
|
|
import encodings.idna
|
|
|
|
|
2016-03-03 17:02:27 +02:00
|
|
|
from .route import Route
|
|
|
|
from ..config import Config
|
2016-04-15 18:57:06 +03:00
|
|
|
from ..compute import MODULES
|
|
|
|
from ..compute.port_manager import PortManager
|
2023-11-06 04:32:23 +02:00
|
|
|
from ..utils.images import list_images
|
2016-04-19 16:35:50 +03:00
|
|
|
from ..controller import Controller
|
2018-01-29 13:13:20 +02:00
|
|
|
|
2015-02-27 04:31:18 +02:00
|
|
|
# do not delete this import
|
|
|
|
import gns3server.handlers
|
2015-01-14 02:05:26 +02:00
|
|
|
|
2013-12-05 09:21:06 +02:00
|
|
|
import logging
|
|
|
|
log = logging.getLogger(__name__)
|
2013-10-30 23:58:17 +02:00
|
|
|
|
2018-10-16 11:56:06 +03:00
|
|
|
if not (aiohttp.__version__.startswith("3.")):
|
|
|
|
raise RuntimeError("aiohttp 3.x is required to run the GNS3 server")
|
2017-05-31 17:56:28 +03:00
|
|
|
|
2014-09-30 00:56:01 +03:00
|
|
|
|
2016-03-03 17:02:27 +02:00
|
|
|
class WebServer:
|
2013-10-30 23:58:17 +02:00
|
|
|
|
2016-06-16 02:37:43 +03:00
|
|
|
def __init__(self, host, port):
|
2013-10-30 23:58:17 +02:00
|
|
|
|
2013-12-05 09:21:06 +02:00
|
|
|
self._host = host
|
|
|
|
self._port = port
|
2015-01-14 02:05:26 +02:00
|
|
|
self._loop = None
|
2015-03-13 02:44:05 +02:00
|
|
|
self._handler = None
|
2016-09-08 12:23:13 +03:00
|
|
|
self._server = None
|
|
|
|
self._app = None
|
2015-01-14 02:05:26 +02:00
|
|
|
self._start_time = time.time()
|
2016-06-16 02:37:43 +03:00
|
|
|
self._running = False
|
2016-08-26 15:14:19 +03:00
|
|
|
self._closing = False
|
2020-10-27 14:55:19 +02:00
|
|
|
self._ssl_context = None
|
2014-11-10 08:01:13 +02:00
|
|
|
|
2015-03-13 02:44:05 +02:00
|
|
|
@staticmethod
|
2016-06-16 02:37:43 +03:00
|
|
|
def instance(host=None, port=None):
|
2015-03-13 02:44:05 +02:00
|
|
|
"""
|
|
|
|
Singleton to return only one instance of Server.
|
|
|
|
|
|
|
|
:returns: instance of Server
|
|
|
|
"""
|
|
|
|
|
2016-03-03 17:02:27 +02:00
|
|
|
if not hasattr(WebServer, "_instance") or WebServer._instance is None:
|
2015-03-13 02:50:38 +02:00
|
|
|
assert host is not None
|
|
|
|
assert port is not None
|
2016-06-16 02:37:43 +03:00
|
|
|
WebServer._instance = WebServer(host, port)
|
2016-03-03 17:02:27 +02:00
|
|
|
return WebServer._instance
|
2015-03-13 02:44:05 +02:00
|
|
|
|
2015-02-22 21:36:44 +02:00
|
|
|
def _run_application(self, handler, ssl_context=None):
|
2015-02-02 00:56:10 +02:00
|
|
|
try:
|
2016-12-05 11:28:11 +02:00
|
|
|
srv = self._loop.create_server(handler, self._host, self._port, ssl=ssl_context)
|
2021-08-15 08:39:48 +03:00
|
|
|
self._server, startup_res = self._loop.run_until_complete(asyncio.gather(srv, self._app.startup()))
|
2017-10-01 19:47:16 +03:00
|
|
|
except (RuntimeError, OSError, asyncio.CancelledError) as e:
|
2015-02-02 00:56:10 +02:00
|
|
|
log.critical("Could not start the server: {}".format(e))
|
2016-08-31 10:57:37 +03:00
|
|
|
return False
|
2023-11-06 04:32:23 +02:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
return False
|
2016-09-08 12:23:13 +03:00
|
|
|
return True
|
2015-01-14 02:05:26 +02:00
|
|
|
|
2020-04-30 09:00:50 +03:00
|
|
|
async def reload_server(self):
|
|
|
|
"""
|
|
|
|
Reload the server.
|
|
|
|
"""
|
|
|
|
|
|
|
|
await Controller.instance().reload()
|
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
async def shutdown_server(self):
|
2013-12-06 06:39:27 +02:00
|
|
|
"""
|
2015-03-13 02:44:05 +02:00
|
|
|
Cleanly shutdown the server.
|
2013-10-30 23:58:17 +02:00
|
|
|
"""
|
|
|
|
|
2016-08-26 15:14:19 +03:00
|
|
|
if not self._closing:
|
|
|
|
self._closing = True
|
|
|
|
else:
|
|
|
|
log.warning("Close is already in progress")
|
|
|
|
return
|
|
|
|
|
2018-10-16 11:56:06 +03:00
|
|
|
# close websocket connections
|
2018-12-03 13:14:22 +02:00
|
|
|
websocket_connections = set(self._app['websockets'])
|
|
|
|
if websocket_connections:
|
|
|
|
log.info("Closing {} websocket connections...".format(len(websocket_connections)))
|
|
|
|
for ws in websocket_connections:
|
2018-10-16 11:56:06 +03:00
|
|
|
await ws.close(code=aiohttp.WSCloseCode.GOING_AWAY, message='Server shutdown')
|
|
|
|
|
2016-09-08 12:23:13 +03:00
|
|
|
if self._server:
|
|
|
|
self._server.close()
|
2024-05-09 12:37:45 +03:00
|
|
|
# await self._server.wait_closed()
|
2016-09-08 12:23:13 +03:00
|
|
|
if self._app:
|
2018-10-15 13:05:49 +03:00
|
|
|
await self._app.shutdown()
|
2015-03-13 02:44:05 +02:00
|
|
|
if self._handler:
|
2018-10-16 11:56:06 +03:00
|
|
|
await self._handler.shutdown(2) # Parameter is timeout
|
2016-09-08 12:23:13 +03:00
|
|
|
if self._app:
|
2018-10-15 13:05:49 +03:00
|
|
|
await self._app.cleanup()
|
2015-03-13 02:44:05 +02:00
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
await Controller.instance().stop()
|
2016-06-02 14:44:12 +03:00
|
|
|
|
2015-01-22 12:49:22 +02:00
|
|
|
for module in MODULES:
|
|
|
|
log.debug("Unloading module {}".format(module.__name__))
|
|
|
|
m = module.instance()
|
2018-10-15 13:05:49 +03:00
|
|
|
await m.unload()
|
2015-02-24 02:42:55 +02:00
|
|
|
|
2016-10-26 15:43:47 +03:00
|
|
|
if PortManager.instance().tcp_ports:
|
|
|
|
log.warning("TCP ports are still used {}".format(PortManager.instance().tcp_ports))
|
2015-02-24 02:42:55 +02:00
|
|
|
|
2016-10-26 15:43:47 +03:00
|
|
|
if PortManager.instance().udp_ports:
|
|
|
|
log.warning("UDP ports are still used {}".format(PortManager.instance().udp_ports))
|
2015-02-24 02:42:55 +02:00
|
|
|
|
2020-11-17 08:21:26 +02:00
|
|
|
try:
|
|
|
|
tasks = asyncio.all_tasks()
|
|
|
|
except AttributeError:
|
|
|
|
tasks = asyncio.Task.all_tasks()
|
|
|
|
|
|
|
|
for task in tasks:
|
2015-10-16 21:42:13 +03:00
|
|
|
task.cancel()
|
2016-08-18 16:04:43 +03:00
|
|
|
try:
|
2018-10-15 13:05:49 +03:00
|
|
|
await asyncio.wait_for(task, 1)
|
2017-07-12 11:57:03 +03:00
|
|
|
except BaseException:
|
2016-08-18 16:04:43 +03:00
|
|
|
pass
|
2015-10-16 21:42:13 +03:00
|
|
|
|
2015-01-14 02:05:26 +02:00
|
|
|
self._loop.stop()
|
2014-03-16 05:41:04 +02:00
|
|
|
|
2020-10-27 14:55:19 +02:00
|
|
|
def ssl_context(self):
|
|
|
|
"""
|
|
|
|
Returns the SSL context for the server.
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self._ssl_context
|
|
|
|
|
2015-03-13 02:44:05 +02:00
|
|
|
def _signal_handling(self):
|
2014-05-08 04:31:53 +03:00
|
|
|
|
2016-05-30 16:28:53 +03:00
|
|
|
def signal_handler(signame, *args):
|
2020-04-30 09:00:50 +03:00
|
|
|
|
2018-08-28 11:42:06 +03:00
|
|
|
try:
|
2020-04-30 09:00:50 +03:00
|
|
|
if signame == "SIGHUP":
|
|
|
|
log.info("Server has got signal {}, reloading...".format(signame))
|
|
|
|
asyncio.ensure_future(self.reload_server())
|
|
|
|
else:
|
|
|
|
log.warning("Server has got signal {}, exiting...".format(signame))
|
|
|
|
asyncio.ensure_future(self.shutdown_server())
|
2018-08-28 11:42:06 +03:00
|
|
|
except asyncio.CancelledError:
|
|
|
|
pass
|
2015-01-14 02:05:26 +02:00
|
|
|
|
|
|
|
signals = ["SIGTERM", "SIGINT"]
|
|
|
|
if sys.platform.startswith("win"):
|
|
|
|
signals.extend(["SIGBREAK"])
|
|
|
|
else:
|
|
|
|
signals.extend(["SIGHUP", "SIGQUIT"])
|
2014-03-16 05:41:04 +02:00
|
|
|
|
2015-01-14 02:05:26 +02:00
|
|
|
for signal_name in signals:
|
2015-10-12 17:16:44 +03:00
|
|
|
callback = functools.partial(signal_handler, signal_name)
|
2015-01-14 02:05:26 +02:00
|
|
|
if sys.platform.startswith("win"):
|
|
|
|
# add_signal_handler() is not yet supported on Windows
|
|
|
|
signal.signal(getattr(signal, signal_name), callback)
|
|
|
|
else:
|
|
|
|
self._loop.add_signal_handler(getattr(signal, signal_name), callback)
|
|
|
|
|
2015-01-24 21:11:51 +02:00
|
|
|
def _create_ssl_context(self, server_config):
|
|
|
|
|
|
|
|
import ssl
|
|
|
|
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
|
|
|
certfile = server_config["certfile"]
|
|
|
|
certkey = server_config["certkey"]
|
|
|
|
try:
|
|
|
|
ssl_context.load_cert_chain(certfile, certkey)
|
|
|
|
except FileNotFoundError:
|
|
|
|
log.critical("Could not find the SSL certfile or certkey")
|
|
|
|
raise SystemExit
|
|
|
|
except ssl.SSLError as e:
|
|
|
|
log.critical("SSL error: {}".format(e))
|
|
|
|
raise SystemExit
|
2015-06-11 18:07:13 +03:00
|
|
|
log.info("SSL is enabled")
|
2015-01-24 21:11:51 +02:00
|
|
|
return ssl_context
|
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
async def start_shell(self):
|
2019-03-20 10:23:30 +02:00
|
|
|
|
|
|
|
log.error("The embedded shell has been deactivated in this version of GNS3")
|
|
|
|
return
|
2015-02-24 02:08:34 +02:00
|
|
|
try:
|
|
|
|
from ptpython.repl import embed
|
|
|
|
except ImportError:
|
|
|
|
log.error("Unable to start a shell: the ptpython module must be installed!")
|
|
|
|
return
|
2018-10-15 13:05:49 +03:00
|
|
|
await embed(globals(), locals(), return_asyncio_coroutine=True, patch_stdout=True, history_filename=".gns3_shell_history")
|
2015-02-20 23:40:20 +02:00
|
|
|
|
2015-05-05 12:33:47 +03:00
|
|
|
def _exit_handling(self):
|
2015-07-21 01:02:28 +03:00
|
|
|
"""
|
|
|
|
Makes sure the asyncio loop is closed.
|
|
|
|
"""
|
|
|
|
|
2015-05-05 12:33:47 +03:00
|
|
|
def close_asyncio_loop():
|
|
|
|
loop = None
|
|
|
|
try:
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
if loop is not None:
|
|
|
|
loop.close()
|
|
|
|
|
|
|
|
atexit.register(close_asyncio_loop)
|
|
|
|
|
2023-11-06 04:32:23 +02:00
|
|
|
async def _compute_image_checksums(self):
|
|
|
|
"""
|
|
|
|
Compute image checksums.
|
|
|
|
"""
|
|
|
|
|
2023-11-07 06:30:39 +02:00
|
|
|
if sys.platform.startswith("darwin") and hasattr(sys, "frozen"):
|
|
|
|
# do not compute on macOS because errors
|
|
|
|
return
|
2023-11-06 04:32:23 +02:00
|
|
|
loop = asyncio.get_event_loop()
|
2023-11-07 06:30:39 +02:00
|
|
|
import concurrent.futures
|
2023-11-06 04:32:23 +02:00
|
|
|
with concurrent.futures.ProcessPoolExecutor(max_workers=1) as pool:
|
2023-11-07 03:08:47 +02:00
|
|
|
try:
|
|
|
|
log.info("Computing image checksums...")
|
|
|
|
await loop.run_in_executor(pool, list_images, "qemu")
|
|
|
|
log.info("Finished computing image checksums")
|
|
|
|
except OSError as e:
|
|
|
|
log.warning("Could not compute image checksums: {}".format(e))
|
2023-11-06 04:32:23 +02:00
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
async def _on_startup(self, *args):
|
2017-03-21 19:06:45 +02:00
|
|
|
"""
|
|
|
|
Called when the HTTP server start
|
|
|
|
"""
|
2020-04-30 09:19:06 +03:00
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
await Controller.instance().start()
|
2023-11-06 04:32:23 +02:00
|
|
|
|
|
|
|
# Start computing checksums now because it can take a long time
|
|
|
|
# for a large image collection
|
|
|
|
await self._compute_image_checksums()
|
2017-03-21 19:06:45 +02:00
|
|
|
|
2013-10-30 23:58:17 +02:00
|
|
|
def run(self):
|
2013-12-05 09:21:06 +02:00
|
|
|
"""
|
2015-01-14 02:05:26 +02:00
|
|
|
Starts the server.
|
2013-10-30 23:58:17 +02:00
|
|
|
"""
|
|
|
|
|
2016-12-19 12:11:51 +02:00
|
|
|
server_logger = logging.getLogger('aiohttp.server')
|
|
|
|
# In debug mode we don't use the standard request log but a more complete in response.py
|
|
|
|
if log.getEffectiveLevel() == logging.DEBUG:
|
|
|
|
server_logger.setLevel(logging.CRITICAL)
|
|
|
|
|
2015-01-21 00:28:40 +02:00
|
|
|
logger = logging.getLogger("asyncio")
|
2015-10-14 19:10:05 +03:00
|
|
|
logger.setLevel(logging.ERROR)
|
2015-01-21 00:28:40 +02:00
|
|
|
|
2015-01-23 06:11:57 +02:00
|
|
|
if sys.platform.startswith("win"):
|
2016-05-30 16:18:49 +03:00
|
|
|
loop = asyncio.get_event_loop()
|
2015-02-27 21:51:39 +02:00
|
|
|
# Add a periodic callback to give a chance to process signals on Windows
|
|
|
|
# because asyncio.add_signal_handler() is not supported yet on that platform
|
|
|
|
# otherwise the loop runs outside of signal module's ability to trap signals.
|
2016-06-02 14:44:12 +03:00
|
|
|
|
2015-02-27 21:51:39 +02:00
|
|
|
def wakeup():
|
2015-03-14 02:57:27 +02:00
|
|
|
loop.call_later(0.5, wakeup)
|
|
|
|
loop.call_later(0.5, wakeup)
|
2015-01-23 06:11:57 +02:00
|
|
|
|
2016-05-30 16:18:49 +03:00
|
|
|
server_config = Config.instance().get_section_config("Server")
|
|
|
|
|
2020-10-27 14:55:19 +02:00
|
|
|
self._ssl_context = None
|
2015-01-24 21:11:51 +02:00
|
|
|
if server_config.getboolean("ssl"):
|
|
|
|
if sys.platform.startswith("win"):
|
|
|
|
log.critical("SSL mode is not supported on Windows")
|
|
|
|
raise SystemExit
|
2020-10-27 14:55:19 +02:00
|
|
|
self._ssl_context = self._create_ssl_context(server_config)
|
2015-01-24 21:11:51 +02:00
|
|
|
|
2015-01-14 02:05:26 +02:00
|
|
|
self._loop = asyncio.get_event_loop()
|
2017-10-26 13:24:01 +03:00
|
|
|
|
2017-10-26 14:37:50 +03:00
|
|
|
if log.getEffectiveLevel() == logging.DEBUG:
|
|
|
|
# On debug version we enable info that
|
2018-10-15 13:05:49 +03:00
|
|
|
# coroutine is not called in a way await/await
|
2017-10-26 13:24:01 +03:00
|
|
|
self._loop.set_debug(True)
|
2015-10-12 17:26:07 +03:00
|
|
|
|
2016-01-15 11:11:32 +02:00
|
|
|
for key, val in os.environ.items():
|
|
|
|
log.debug("ENV %s=%s", key, val)
|
|
|
|
|
2016-09-08 12:23:13 +03:00
|
|
|
self._app = aiohttp.web.Application()
|
2018-10-16 11:56:06 +03:00
|
|
|
|
|
|
|
# Keep a list of active websocket connections
|
|
|
|
self._app['websockets'] = weakref.WeakSet()
|
|
|
|
|
2017-03-21 19:06:45 +02:00
|
|
|
# Background task started with the server
|
|
|
|
self._app.on_startup.append(self._on_startup)
|
2016-12-05 11:28:11 +02:00
|
|
|
|
2023-12-06 14:33:55 +02:00
|
|
|
resource_options = aiohttp_cors.ResourceOptions(allow_credentials=True, expose_headers="*", allow_headers="*", max_age=0)
|
2018-11-06 14:31:14 +02:00
|
|
|
|
2016-05-17 13:39:23 +03:00
|
|
|
# Allow CORS for this domains
|
2016-09-08 12:23:13 +03:00
|
|
|
cors = aiohttp_cors.setup(self._app, defaults={
|
2016-05-17 13:39:23 +03:00
|
|
|
# Default web server for web gui dev
|
2023-12-06 14:33:55 +02:00
|
|
|
"http://127.0.0.1:3080": resource_options,
|
|
|
|
"http://localhost:3080": resource_options,
|
2018-11-06 14:31:14 +02:00
|
|
|
"http://127.0.0.1:4200": resource_options,
|
|
|
|
"http://localhost:4200": resource_options,
|
|
|
|
"http://gns3.github.io": resource_options,
|
|
|
|
"https://gns3.github.io": resource_options
|
2016-05-17 13:39:23 +03:00
|
|
|
})
|
2016-10-26 15:43:47 +03:00
|
|
|
|
|
|
|
PortManager.instance().console_host = self._host
|
|
|
|
|
2015-01-14 02:05:26 +02:00
|
|
|
for method, route, handler in Route.get_routes():
|
2015-01-20 15:59:19 +02:00
|
|
|
log.debug("Adding route: {} {}".format(method, route))
|
2016-09-08 12:23:13 +03:00
|
|
|
cors.add(self._app.router.add_route(method, route, handler))
|
2018-10-23 12:09:38 +03:00
|
|
|
|
2015-01-14 02:05:26 +02:00
|
|
|
for module in MODULES:
|
2015-01-20 15:59:19 +02:00
|
|
|
log.debug("Loading module {}".format(module.__name__))
|
2015-01-15 17:59:01 +02:00
|
|
|
m = module.instance()
|
2016-10-26 15:43:47 +03:00
|
|
|
m.port_manager = PortManager.instance()
|
2013-12-07 02:52:16 +02:00
|
|
|
|
2015-01-20 15:59:19 +02:00
|
|
|
log.info("Starting server on {}:{}".format(self._host, self._port))
|
2016-12-19 12:11:51 +02:00
|
|
|
|
|
|
|
self._handler = self._app.make_handler()
|
2020-10-27 14:55:19 +02:00
|
|
|
if self._run_application(self._handler, self._ssl_context) is False:
|
2016-08-31 10:57:37 +03:00
|
|
|
self._loop.stop()
|
2020-04-28 08:09:28 +03:00
|
|
|
sys.exit(1)
|
2016-08-16 17:04:20 +03:00
|
|
|
|
2015-03-13 02:44:05 +02:00
|
|
|
self._signal_handling()
|
2015-05-05 12:33:47 +03:00
|
|
|
self._exit_handling()
|
|
|
|
|
2015-02-20 23:40:20 +02:00
|
|
|
if server_config.getboolean("shell"):
|
2018-10-15 13:05:49 +03:00
|
|
|
asyncio.ensure_future(self.start_shell())
|
2015-02-20 23:40:20 +02:00
|
|
|
|
2015-03-13 02:48:07 +02:00
|
|
|
try:
|
|
|
|
self._loop.run_forever()
|
2023-11-05 07:41:46 +02:00
|
|
|
except ConnectionResetError:
|
|
|
|
log.warning("Connection reset by peer")
|
2015-03-13 02:48:07 +02:00
|
|
|
except TypeError as e:
|
|
|
|
# This is to ignore an asyncio.windows_events exception
|
2015-03-13 02:50:38 +02:00
|
|
|
# on Windows when the process gets the SIGBREAK signal
|
2015-03-13 02:48:07 +02:00
|
|
|
# TypeError: async() takes 1 positional argument but 3 were given
|
|
|
|
log.warning("TypeError exception in the loop {}".format(e))
|
2015-07-21 01:02:28 +03:00
|
|
|
finally:
|
2015-07-27 00:27:47 +03:00
|
|
|
if self._loop.is_running():
|
2018-08-28 11:42:06 +03:00
|
|
|
try:
|
|
|
|
self._loop.run_until_complete(self.shutdown_server())
|
|
|
|
except asyncio.CancelledError:
|
|
|
|
pass
|
2020-04-28 08:09:28 +03:00
|
|
|
|