Prevent close server process to be started twice

Fix #652
This commit is contained in:
Julien Duponchelle committed 2016-08-26 14:14:19 +02:00
1 parent 8352ff02a1
commit f93e443548
1 file changed
+7
+7
View File
@@ -60,6 +60,7 @@ class WebServer:
self._start_time = time.time()
self._port_manager = PortManager(host)
self._running = False
self._closing = False
@staticmethod
def instance(host=None, port=None):
@@ -92,6 +93,12 @@ class WebServer:
Cleanly shutdown the server.
"""
if not self._closing:
self._closing = True
else:
log.warning("Close is already in progress")
return
if self._handler:
yield from self._handler.finish_connections()
self._handler = None