diff --git a/dev-requirements.txt b/dev-requirements.txt index 081fea50d..df3f6b494 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ pytest==8.4.2 # version 8.4.2 is the last one supporting Python 3.9 flake8==7.3.0 pytest-timeout==2.4.0 -pytest-asyncio==1.0.0 # upgrading leads to stuck tests +pytest-asyncio==0.26.0 # upgrading leads to stuck / failed tests requests==2.32.5 httpx==0.28.1 httpx_ws==0.7.1 # upgrading leads to failures in tests \ No newline at end of file diff --git a/gns3server/compute/base_manager.py b/gns3server/compute/base_manager.py index 48082e579..17a41fe7e 100644 --- a/gns3server/compute/base_manager.py +++ b/gns3server/compute/base_manager.py @@ -24,6 +24,7 @@ import socket import shutil import re import logging +import inspect log = logging.getLogger(__name__) @@ -196,7 +197,7 @@ class BaseManager: node_id = str(uuid4()) node = self._NODE_CLASS(name, node_id, project, self, *args, **kwargs) - if asyncio.iscoroutinefunction(node.create): + if inspect.iscoroutinefunction(node.create): await node.create() else: node.create() @@ -245,7 +246,7 @@ class BaseManager: """ node = self.get_node(node_id) - if asyncio.iscoroutinefunction(node.close): + if inspect.iscoroutinefunction(node.close): await node.close() else: node.close() diff --git a/gns3server/utils/asyncio/__init__.py b/gns3server/utils/asyncio/__init__.py index 131145eb9..34ae5d441 100644 --- a/gns3server/utils/asyncio/__init__.py +++ b/gns3server/utils/asyncio/__init__.py @@ -20,6 +20,7 @@ import asyncio import sys import os import threading +import inspect async def wait_run_in_executor(func, *args, **kwargs): @@ -103,7 +104,7 @@ async def wait_for_process_termination(process, timeout=10): async def _check_process(process, termination_callback): if not hasattr(sys, "_called_from_test") or not sys._called_from_test: returncode = await process.wait() - if asyncio.iscoroutinefunction(termination_callback): + if inspect.iscoroutinefunction(termination_callback): await termination_callback(returncode) else: termination_callback(returncode) diff --git a/requirements.txt b/requirements.txt index 63ef755bf..527d08c33 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,8 +11,8 @@ psutil>=7.2.1 async-timeout>=5.0.1,<5.1; python_version < '3.11' # this library has effectively been upstreamed into Python 3.11+ distro>=1.9.0 py-cpuinfo>=9.0.0,<10.0 -greenlet==3.2.0 # necessary to run sqlalchemy on Python 3.13 -sqlalchemy==2.0.46 +greenlet==3.3.1; python_version >= '3.13' # necessary to run sqlalchemy on Python >= 3.13 +sqlalchemy==2.0.43 aiosqlite==0.21.0 alembic==1.15.2 bcrypt==5.0.0 diff --git a/tests/utils/test_asyncio.py b/tests/utils/test_asyncio.py index 1b0056587..cb59bfe39 100644 --- a/tests/utils/test_asyncio.py +++ b/tests/utils/test_asyncio.py @@ -18,11 +18,9 @@ import asyncio import pytest -import sys -from unittest.mock import MagicMock -from gns3server.utils.asyncio import wait_run_in_executor, subprocess_check_output, wait_for_process_termination, locking -from tests.utils import AsyncioMagicMock +from gns3server.utils.asyncio import wait_run_in_executor, subprocess_check_output, locking + @pytest.mark.asyncio