mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fix issue with notification queue that prevented to properly close projects. Fix #1493
This commit is contained in:
1 parent
161c05a310
commit
a896346c77
4 files changed
+34
-29
No files matched your search
@@ -67,16 +67,16 @@ class NotificationHandler:
|
||||
|
||||
request.app['websockets'].add(ws)
|
||||
asyncio.ensure_future(process_websocket(ws))
|
||||
with controller.notification.controller_queue() as queue:
|
||||
try:
|
||||
try:
|
||||
with controller.notification.controller_queue() as queue:
|
||||
while True:
|
||||
notification = await queue.get_json(5)
|
||||
if ws.closed:
|
||||
break
|
||||
await ws.send_str(notification)
|
||||
finally:
|
||||
if not ws.closed:
|
||||
await ws.close()
|
||||
request.app['websockets'].discard(ws)
|
||||
finally:
|
||||
if not ws.closed:
|
||||
await ws.close()
|
||||
request.app['websockets'].discard(ws)
|
||||
|
||||
return ws
|
||||
@@ -259,24 +259,24 @@ class ProjectHandler:
|
||||
|
||||
request.app['websockets'].add(ws)
|
||||
asyncio.ensure_future(process_websocket(ws))
|
||||
with controller.notification.project_queue(project) as queue:
|
||||
try:
|
||||
try:
|
||||
with controller.notification.project_queue(project) as queue:
|
||||
while True:
|
||||
notification = await queue.get_json(5)
|
||||
if ws.closed:
|
||||
break
|
||||
await ws.send_str(notification)
|
||||
finally:
|
||||
if not ws.closed:
|
||||
await ws.close()
|
||||
request.app['websockets'].discard(ws)
|
||||
finally:
|
||||
if not ws.closed:
|
||||
await ws.close()
|
||||
request.app['websockets'].discard(ws)
|
||||
|
||||
if project.auto_close:
|
||||
# To avoid trouble with client connecting disconnecting we sleep few seconds before checking
|
||||
# if someone else is not connected
|
||||
await asyncio.sleep(5)
|
||||
if not controller.notification.project_has_listeners(project):
|
||||
await project.close()
|
||||
if project.auto_close:
|
||||
# To avoid trouble with client connecting disconnecting we sleep few seconds before checking
|
||||
# if someone else is not connected
|
||||
await asyncio.sleep(5)
|
||||
if not controller.notification.project_has_listeners(project):
|
||||
await project.close()
|
||||
|
||||
return ws
|
||||
|
||||
|
||||
Reference in new issue
Block a user