mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-03-15 01:43:34 +02:00
Fix issue with notification queue that prevented to properly close projects. Fix #1493
This commit is contained in:
parent
161c05a310
commit
a896346c77
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from ..notification_queue import NotificationQueue
|
from ..notification_queue import NotificationQueue
|
||||||
@ -43,7 +42,9 @@ class Notification:
|
|||||||
queue = NotificationQueue()
|
queue = NotificationQueue()
|
||||||
self._project_listeners.setdefault(project.id, set())
|
self._project_listeners.setdefault(project.id, set())
|
||||||
self._project_listeners[project.id].add(queue)
|
self._project_listeners[project.id].add(queue)
|
||||||
|
try:
|
||||||
yield queue
|
yield queue
|
||||||
|
finally:
|
||||||
self._project_listeners[project.id].remove(queue)
|
self._project_listeners[project.id].remove(queue)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
@ -55,7 +56,9 @@ class Notification:
|
|||||||
"""
|
"""
|
||||||
queue = NotificationQueue()
|
queue = NotificationQueue()
|
||||||
self._controller_listeners.append(queue)
|
self._controller_listeners.append(queue)
|
||||||
|
try:
|
||||||
yield queue
|
yield queue
|
||||||
|
finally:
|
||||||
self._controller_listeners.remove(queue)
|
self._controller_listeners.remove(queue)
|
||||||
|
|
||||||
def controller_emit(self, action, event):
|
def controller_emit(self, action, event):
|
||||||
|
@ -44,8 +44,9 @@ class NotificationHandler:
|
|||||||
|
|
||||||
request.app['websockets'].add(ws)
|
request.app['websockets'].add(ws)
|
||||||
asyncio.ensure_future(process_websocket(ws))
|
asyncio.ensure_future(process_websocket(ws))
|
||||||
with notifications.queue() as queue:
|
|
||||||
try:
|
try:
|
||||||
|
with notifications.queue() as queue:
|
||||||
while True:
|
while True:
|
||||||
notification = await queue.get_json(1)
|
notification = await queue.get_json(1)
|
||||||
if ws.closed:
|
if ws.closed:
|
||||||
@ -55,4 +56,5 @@ class NotificationHandler:
|
|||||||
if not ws.closed:
|
if not ws.closed:
|
||||||
await ws.close()
|
await ws.close()
|
||||||
request.app['websockets'].discard(ws)
|
request.app['websockets'].discard(ws)
|
||||||
|
|
||||||
return ws
|
return ws
|
||||||
|
@ -67,8 +67,8 @@ class NotificationHandler:
|
|||||||
|
|
||||||
request.app['websockets'].add(ws)
|
request.app['websockets'].add(ws)
|
||||||
asyncio.ensure_future(process_websocket(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:
|
while True:
|
||||||
notification = await queue.get_json(5)
|
notification = await queue.get_json(5)
|
||||||
if ws.closed:
|
if ws.closed:
|
||||||
|
@ -259,8 +259,8 @@ class ProjectHandler:
|
|||||||
|
|
||||||
request.app['websockets'].add(ws)
|
request.app['websockets'].add(ws)
|
||||||
asyncio.ensure_future(process_websocket(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:
|
while True:
|
||||||
notification = await queue.get_json(5)
|
notification = await queue.get_json(5)
|
||||||
if ws.closed:
|
if ws.closed:
|
||||||
|
Loading…
Reference in New Issue
Block a user