diff --git a/conda-environment.yml b/conda-environment.yml index 6d31dce548..fed33d57a8 100644 --- a/conda-environment.yml +++ b/conda-environment.yml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - ansimarkup >=1.0.0 - - async-timeout>=3.0.0 + - async-timeout>=3.0.0 # [py<3.11] - colorama >=0.4,<1.0 - graphene >=2.1,<3 - graphviz # for static graphing diff --git a/cylc/flow/network/ssh_client.py b/cylc/flow/network/ssh_client.py index d2ed0dd33e..a68a16876b 100644 --- a/cylc/flow/network/ssh_client.py +++ b/cylc/flow/network/ssh_client.py @@ -14,17 +14,36 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from async_timeout import timeout as asyncto import asyncio import json import os -from typing import Any, List, Optional, Tuple, Union, Dict +import sys +from typing import ( + Any, + Dict, + List, + Optional, + Tuple, + Union, +) -from cylc.flow.exceptions import ClientError, ClientTimeout +from cylc.flow.exceptions import ( + ClientError, + ClientTimeout, +) from cylc.flow.network.client import WorkflowRuntimeClientBase from cylc.flow.network.client_factory import CommsMeth from cylc.flow.remote import remote_cylc_cmd -from cylc.flow.workflow_files import load_contact_file, ContactFileFields +from cylc.flow.workflow_files import ( + ContactFileFields, + load_contact_file, +) + + +if sys.version_info[:2] >= (3, 11): + from asyncio import timeout as asyncto +else: + from async_timeout import timeout as asyncto class WorkflowRuntimeClient(WorkflowRuntimeClientBase): diff --git a/setup.cfg b/setup.cfg index 3dfba8e9a7..abdf10fd75 100644 --- a/setup.cfg +++ b/setup.cfg @@ -63,7 +63,7 @@ include_package_data = True python_requires = >=3.7 install_requires = ansimarkup>=1.0.0 - async-timeout>=3.0.0 + async-timeout>=3.0.0; python_version < "3.11" colorama>=0.4,<1 graphene>=2.1,<3 # Note: can't pin jinja2 any higher than this until we give up on Cylc 7 back-compat diff --git a/tests/integration/test_publisher.py b/tests/integration/test_publisher.py index c1fe7e1bcd..4e7d00cd52 100644 --- a/tests/integration/test_publisher.py +++ b/tests/integration/test_publisher.py @@ -13,15 +13,20 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from async_timeout import timeout -import pytest +import sys from cylc.flow.network.subscriber import ( WorkflowSubscriber, - process_delta_msg + process_delta_msg, ) +if sys.version_info[:2] >= (3, 11): + from asyncio import timeout +else: + from async_timeout import timeout + + async def test_publisher(flow, scheduler, run, one_conf, port_range): """It should publish deltas when the flow starts.""" id_ = flow(one_conf) diff --git a/tests/integration/test_replier.py b/tests/integration/test_replier.py index ce0b53fdaa..3f7334eca9 100644 --- a/tests/integration/test_replier.py +++ b/tests/integration/test_replier.py @@ -14,13 +14,18 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from async_timeout import timeout +import sys from cylc.flow.network import decode_ from cylc.flow.network.client import WorkflowRuntimeClient import asyncio import pytest +if sys.version_info[:2] >= (3, 11): + from asyncio import timeout +else: + from async_timeout import timeout + async def test_listener(one, start, ): """Test listener.""" diff --git a/tests/integration/test_server.py b/tests/integration/test_server.py index bc7103b836..b8c46b1a2c 100644 --- a/tests/integration/test_server.py +++ b/tests/integration/test_server.py @@ -14,9 +14,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from typing import Callable -from async_timeout import timeout from getpass import getuser +import sys +from typing import Callable import pytest @@ -24,6 +24,12 @@ from cylc.flow.scheduler import Scheduler +if sys.version_info[:2] >= (3, 11): + from asyncio import timeout +else: + from async_timeout import timeout + + @pytest.fixture(scope='module') async def myflow(mod_flow, mod_scheduler, mod_run, mod_one_conf): id_ = mod_flow(mod_one_conf) diff --git a/tests/integration/test_workflow_events.py b/tests/integration/test_workflow_events.py index b41b03e721..c086ca6475 100644 --- a/tests/integration/test_workflow_events.py +++ b/tests/integration/test_workflow_events.py @@ -15,13 +15,19 @@ # along with this program. If not, see . import asyncio +import sys -from async_timeout import timeout as async_timeout import pytest from cylc.flow.scheduler import SchedulerError +if sys.version_info[:2] >= (3, 11): + from asyncio import timeout as async_timeout +else: + from async_timeout import timeout as async_timeout + + EVENTS = ( 'startup', 'shutdown', diff --git a/tests/integration/tui/test_updater.py b/tests/integration/tui/test_updater.py index 3fa310b696..0077fa6204 100644 --- a/tests/integration/tui/test_updater.py +++ b/tests/integration/tui/test_updater.py @@ -19,9 +19,9 @@ from pathlib import Path from queue import Queue import re +import sys from time import time -from async_timeout import timeout import pytest from cylc.flow.cycling.integer import IntegerPoint @@ -33,6 +33,12 @@ from cylc.flow.workflow_status import WorkflowStatus +if sys.version_info[:2] >= (3, 11): + from asyncio import timeout +else: + from async_timeout import timeout + + @pytest.fixture def updater(monkeypatch, test_dir): """Return an updater ready for testing.""" diff --git a/tests/integration/utils/flow_tools.py b/tests/integration/utils/flow_tools.py index ba5e3d0470..7a341e8515 100644 --- a/tests/integration/utils/flow_tools.py +++ b/tests/integration/utils/flow_tools.py @@ -22,23 +22,40 @@ """ import asyncio -from pathlib import Path -from async_timeout import timeout -from contextlib import asynccontextmanager, contextmanager +from contextlib import ( + asynccontextmanager, + contextmanager, +) import logging -import pytest -from typing import Any, Optional, Union +from pathlib import Path from secrets import token_hex +import sys +from typing import ( + Any, + Optional, + Union, +) + +import pytest from cylc.flow import CYLC_LOG -from cylc.flow.workflow_files import WorkflowFiles -from cylc.flow.scheduler import Scheduler, SchedulerStop +from cylc.flow.scheduler import ( + Scheduler, + SchedulerStop, +) from cylc.flow.scheduler_cli import RunOptions +from cylc.flow.workflow_files import WorkflowFiles from cylc.flow.workflow_status import StopMode from .flow_writer import flow_config_str +if sys.version_info[:2] >= (3, 11): + from asyncio import timeout +else: + from async_timeout import timeout + + def _make_src_flow(src_path, conf, filename=WorkflowFiles.FLOW_FILE): """Construct a workflow on the filesystem""" flow_src_dir = (src_path / token_hex(4))