Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Nov 17, 2024
1 parent 31a2cb9 commit b37db57
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions gns3server/compute/notification_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class NotificationManager:

def __init__(self):
self._listeners = set()
self._loop = asyncio.get_event_loop()

@contextmanager
def queue(self):
Expand All @@ -55,7 +54,7 @@ def emit(self, action, event, **kwargs):
"""

for listener in self._listeners:
self._loop.call_soon_threadsafe(listener.put_nowait, (action, event, kwargs))
asyncio.get_event_loop().call_soon(listener.put_nowait, (action, event, kwargs))

@staticmethod
def reset():
Expand Down
7 changes: 3 additions & 4 deletions gns3server/controller/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def __init__(self, controller):
self._controller = controller
self._project_listeners = {}
self._controller_listeners = set()
self._loop = asyncio.get_event_loop()

@contextmanager
def project_queue(self, project_id):
Expand Down Expand Up @@ -74,7 +73,7 @@ def controller_emit(self, action, event):
"""

for controller_listener in self._controller_listeners:
self._loop.call_soon_threadsafe(controller_listener.put_nowait, (action, event, {}))
asyncio.get_event_loop().call_soon_threadsafe(controller_listener.put_nowait, (action, event, {}))

def project_has_listeners(self, project_id):
"""
Expand Down Expand Up @@ -135,7 +134,7 @@ def _send_event_to_project(self, project_id, action, event):
except KeyError:
return
for listener in project_listeners:
self._loop.call_soon_threadsafe(listener.put_nowait, (action, event, {}))
asyncio.get_event_loop().call_soon_threadsafe(listener.put_nowait, (action, event, {}))

def _send_event_to_all_projects(self, action, event):
"""
Expand All @@ -147,4 +146,4 @@ def _send_event_to_all_projects(self, action, event):
"""
for project_listeners in self._project_listeners.values():
for listener in project_listeners:
self._loop.call_soon_threadsafe(listener.put_nowait, (action, event, {}))
asyncio.get_event_loop().call_soon_threadsafe(listener.put_nowait, (action, event, {}))
4 changes: 2 additions & 2 deletions tests/compute/qemu/test_qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ async def test_termination_callback_error(vm, tmpdir):

await queue.get(1) # Ping

(action, event, kwargs) = queue.get_nowait()
(action, event, kwargs) = await queue.get(1)
assert action == "node.updated"
assert event == vm

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

Expand Down

0 comments on commit b37db57

Please sign in to comment.