Skip to content

Commit b37db57

Browse files
committed
Fix tests
1 parent 31a2cb9 commit b37db57

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

gns3server/compute/notification_manager.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class NotificationManager:
2828

2929
def __init__(self):
3030
self._listeners = set()
31-
self._loop = asyncio.get_event_loop()
3231

3332
@contextmanager
3433
def queue(self):
@@ -55,7 +54,7 @@ def emit(self, action, event, **kwargs):
5554
"""
5655

5756
for listener in self._listeners:
58-
self._loop.call_soon_threadsafe(listener.put_nowait, (action, event, kwargs))
57+
asyncio.get_event_loop().call_soon(listener.put_nowait, (action, event, kwargs))
5958

6059
@staticmethod
6160
def reset():

gns3server/controller/notification.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def __init__(self, controller):
3232
self._controller = controller
3333
self._project_listeners = {}
3434
self._controller_listeners = set()
35-
self._loop = asyncio.get_event_loop()
3635

3736
@contextmanager
3837
def project_queue(self, project_id):
@@ -74,7 +73,7 @@ def controller_emit(self, action, event):
7473
"""
7574

7675
for controller_listener in self._controller_listeners:
77-
self._loop.call_soon_threadsafe(controller_listener.put_nowait, (action, event, {}))
76+
asyncio.get_event_loop().call_soon_threadsafe(controller_listener.put_nowait, (action, event, {}))
7877

7978
def project_has_listeners(self, project_id):
8079
"""
@@ -135,7 +134,7 @@ def _send_event_to_project(self, project_id, action, event):
135134
except KeyError:
136135
return
137136
for listener in project_listeners:
138-
self._loop.call_soon_threadsafe(listener.put_nowait, (action, event, {}))
137+
asyncio.get_event_loop().call_soon_threadsafe(listener.put_nowait, (action, event, {}))
139138

140139
def _send_event_to_all_projects(self, action, event):
141140
"""
@@ -147,4 +146,4 @@ def _send_event_to_all_projects(self, action, event):
147146
"""
148147
for project_listeners in self._project_listeners.values():
149148
for listener in project_listeners:
150-
self._loop.call_soon_threadsafe(listener.put_nowait, (action, event, {}))
149+
asyncio.get_event_loop().call_soon_threadsafe(listener.put_nowait, (action, event, {}))

tests/compute/qemu/test_qemu_vm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ async def test_termination_callback_error(vm, tmpdir):
202202

203203
await queue.get(1) # Ping
204204

205-
(action, event, kwargs) = queue.get_nowait()
205+
(action, event, kwargs) = await queue.get(1)
206206
assert action == "node.updated"
207207
assert event == vm
208208

209-
(action, event, kwargs) = queue.get_nowait()
209+
(action, event, kwargs) = await queue.get(1)
210210
assert action == "log.error"
211211
assert event["message"] == "QEMU process has stopped, return code: 1\nBOOMM"
212212

0 commit comments

Comments
 (0)