Handlers: cleanup and fixes.

This commit is contained in:
grossmj
2016-05-13 18:00:07 -06:00
parent 885d93be02
commit f81d35cc29
33 changed files with 723 additions and 766 deletions

View File

@ -17,17 +17,16 @@
import asyncio
from ....web.route import Route
from ....compute.notification_manager import NotificationManager
from aiohttp.web import WebSocketResponse
from gns3server.web.route import Route
from gns3server.compute.notification_manager import NotificationManager
class NotificationHandler:
@classmethod
@Route.get(
r"/notifications/ws",
description="Send notifications about what happend using websockets")
description="Send notifications using Websockets")
def notifications(request, response):
notifications = NotificationManager.instance()
ws = WebSocketResponse()
@ -36,8 +35,8 @@ class NotificationHandler:
with notifications.queue() as queue:
while True:
try:
notif = yield from queue.get_json(5)
except asyncio.futures.CancelledError as e:
notification = yield from queue.get_json(5)
except asyncio.futures.CancelledError:
break
ws.send_str(notif)
ws.send_str(notification)
return ws