forked from openlp/openlp
Call close() to stop everything properly
This commit is contained in:
parent
3e9073275a
commit
f693d3aa37
@ -79,8 +79,8 @@ class WebSocketWorker(ThreadWorker, RegistryProperties, LogMixin):
|
|||||||
address = Settings().value('api/ip address')
|
address = Settings().value('api/ip address')
|
||||||
port = Settings().value('api/websocket port')
|
port = Settings().value('api/websocket port')
|
||||||
# Start the event loop
|
# Start the event loop
|
||||||
event_loop = asyncio.new_event_loop()
|
self.event_loop = asyncio.new_event_loop()
|
||||||
asyncio.set_event_loop(event_loop)
|
asyncio.set_event_loop(self.event_loop)
|
||||||
# Create the websocker server
|
# Create the websocker server
|
||||||
loop = 1
|
loop = 1
|
||||||
self.server = None
|
self.server = None
|
||||||
@ -96,8 +96,8 @@ class WebSocketWorker(ThreadWorker, RegistryProperties, LogMixin):
|
|||||||
log.error('Unable to start WebSocket server {addr}:{port}, giving up'.format(addr=address, port=port))
|
log.error('Unable to start WebSocket server {addr}:{port}, giving up'.format(addr=address, port=port))
|
||||||
if self.server:
|
if self.server:
|
||||||
# If the websocket server exists, start listening
|
# If the websocket server exists, start listening
|
||||||
event_loop.run_until_complete(self.server)
|
self.event_loop.run_until_complete(self.server)
|
||||||
event_loop.run_forever()
|
self.event_loop.run_forever()
|
||||||
self.quit.emit()
|
self.quit.emit()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
@ -108,6 +108,8 @@ class WebSocketWorker(ThreadWorker, RegistryProperties, LogMixin):
|
|||||||
self.server.ws_server.close()
|
self.server.ws_server.close()
|
||||||
elif hasattr(self.server, 'server'):
|
elif hasattr(self.server, 'server'):
|
||||||
self.server.server.close()
|
self.server.server.close()
|
||||||
|
self.event_loop.stop()
|
||||||
|
self.event_loop.close()
|
||||||
|
|
||||||
|
|
||||||
class WebSocketServer(RegistryProperties, LogMixin):
|
class WebSocketServer(RegistryProperties, LogMixin):
|
||||||
|
Loading…
Reference in New Issue
Block a user