1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Merge pull request #2445 from GNS3/bugfix/2426

Fix issue with asyncio.Queue
This commit is contained in:
Jeremy Grossmann 2024-11-18 14:00:20 +10:00 committed by GitHub
commit 8db81de153
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View File

@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import asyncio
from contextlib import contextmanager
from gns3server.utils.notification_queue import NotificationQueue
@ -54,7 +54,7 @@ class NotificationManager:
"""
for listener in self._listeners:
listener.put_nowait((action, event, kwargs))
asyncio.get_event_loop().call_soon_threadsafe(listener.put_nowait, (action, event, kwargs))
@staticmethod
def reset():

View File

@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import asyncio
from contextlib import contextmanager
from gns3server.utils.notification_queue import NotificationQueue
@ -73,7 +73,7 @@ class Notification:
"""
for controller_listener in self._controller_listeners:
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):
"""
@ -134,7 +134,7 @@ class Notification:
except KeyError:
return
for listener in project_listeners:
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):
"""
@ -146,4 +146,4 @@ class Notification:
"""
for project_listeners in self._project_listeners.values():
for listener in project_listeners:
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"