Fix tests

This commit is contained in:
grossmj 2024-11-17 15:00:13 +10:00
parent 31a2cb998d
commit b37db57bb9
No known key found for this signature in database
GPG Key ID: 0A2D76AC45EA25CD
3 changed files with 6 additions and 8 deletions

View File

@ -28,7 +28,6 @@ class NotificationManager:
def __init__(self):
self._listeners = set()
self._loop = asyncio.get_event_loop()
@contextmanager
def queue(self):
@ -55,7 +54,7 @@ class NotificationManager:
"""
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():

View File

@ -32,7 +32,6 @@ class Notification:
self._controller = controller
self._project_listeners = {}
self._controller_listeners = set()
self._loop = asyncio.get_event_loop()
@contextmanager
def project_queue(self, project_id):
@ -74,7 +73,7 @@ class Notification:
"""
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):
"""
@ -135,7 +134,7 @@ class Notification:
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):
"""
@ -147,4 +146,4 @@ class Notification:
"""
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, {}))

View File

@ -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"