Skip to content

Commit 26b12e4

Browse files
Merge pull request #6558 from MetRonnie/async-timeout
Deprecate async-timeout dependency
2 parents bbe7599 + 771298f commit 26b12e4

File tree

9 files changed

+85
-21
lines changed

9 files changed

+85
-21
lines changed

conda-environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
dependencies:
55
- ansimarkup >=1.0.0
6-
- async-timeout>=3.0.0
6+
- async-timeout>=3.0.0 # [py<3.11]
77
- colorama >=0.4,<1.0
88
- graphene >=2.1,<3
99
- graphviz # for static graphing

cylc/flow/network/ssh_client.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,36 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
from async_timeout import timeout as asyncto
1817
import asyncio
1918
import json
2019
import os
21-
from typing import Any, List, Optional, Tuple, Union, Dict
20+
import sys
21+
from typing import (
22+
Any,
23+
Dict,
24+
List,
25+
Optional,
26+
Tuple,
27+
Union,
28+
)
2229

23-
from cylc.flow.exceptions import ClientError, ClientTimeout
30+
from cylc.flow.exceptions import (
31+
ClientError,
32+
ClientTimeout,
33+
)
2434
from cylc.flow.network.client import WorkflowRuntimeClientBase
2535
from cylc.flow.network.client_factory import CommsMeth
2636
from cylc.flow.remote import remote_cylc_cmd
27-
from cylc.flow.workflow_files import load_contact_file, ContactFileFields
37+
from cylc.flow.workflow_files import (
38+
ContactFileFields,
39+
load_contact_file,
40+
)
41+
42+
43+
if sys.version_info[:2] >= (3, 11):
44+
from asyncio import timeout as asyncto
45+
else:
46+
from async_timeout import timeout as asyncto
2847

2948

3049
class WorkflowRuntimeClient(WorkflowRuntimeClientBase):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ include_package_data = True
6363
python_requires = >=3.7
6464
install_requires =
6565
ansimarkup>=1.0.0
66-
async-timeout>=3.0.0
66+
async-timeout>=3.0.0; python_version < "3.11"
6767
colorama>=0.4,<1
6868
graphene>=2.1,<3
6969
# Note: can't pin jinja2 any higher than this until we give up on Cylc 7 back-compat

tests/integration/test_publisher.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@
1313
#
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
from async_timeout import timeout
17-
import pytest
16+
import sys
1817

1918
from cylc.flow.network.subscriber import (
2019
WorkflowSubscriber,
21-
process_delta_msg
20+
process_delta_msg,
2221
)
2322

2423

24+
if sys.version_info[:2] >= (3, 11):
25+
from asyncio import timeout
26+
else:
27+
from async_timeout import timeout
28+
29+
2530
async def test_publisher(flow, scheduler, run, one_conf, port_range):
2631
"""It should publish deltas when the flow starts."""
2732
id_ = flow(one_conf)

tests/integration/test_replier.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
from async_timeout import timeout
17+
import sys
1818
from cylc.flow.network import decode_
1919
from cylc.flow.network.client import WorkflowRuntimeClient
2020
import asyncio
2121

2222
import pytest
2323

24+
if sys.version_info[:2] >= (3, 11):
25+
from asyncio import timeout
26+
else:
27+
from async_timeout import timeout
28+
2429

2530
async def test_listener(one, start, ):
2631
"""Test listener."""

tests/integration/test_server.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
from typing import Callable
18-
from async_timeout import timeout
1917
from getpass import getuser
18+
import sys
19+
from typing import Callable
2020

2121
import pytest
2222

2323
from cylc.flow.network.server import PB_METHOD_MAP
2424
from cylc.flow.scheduler import Scheduler
2525

2626

27+
if sys.version_info[:2] >= (3, 11):
28+
from asyncio import timeout
29+
else:
30+
from async_timeout import timeout
31+
32+
2733
@pytest.fixture(scope='module')
2834
async def myflow(mod_flow, mod_scheduler, mod_run, mod_one_conf):
2935
id_ = mod_flow(mod_one_conf)

tests/integration/test_workflow_events.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
import asyncio
18+
import sys
1819

19-
from async_timeout import timeout as async_timeout
2020
import pytest
2121

2222
from cylc.flow.scheduler import SchedulerError
2323

2424

25+
if sys.version_info[:2] >= (3, 11):
26+
from asyncio import timeout as async_timeout
27+
else:
28+
from async_timeout import timeout as async_timeout
29+
30+
2531
EVENTS = (
2632
'startup',
2733
'shutdown',

tests/integration/tui/test_updater.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from pathlib import Path
2020
from queue import Queue
2121
import re
22+
import sys
2223
from time import time
2324

24-
from async_timeout import timeout
2525
import pytest
2626

2727
from cylc.flow.cycling.integer import IntegerPoint
@@ -33,6 +33,12 @@
3333
from cylc.flow.workflow_status import WorkflowStatus
3434

3535

36+
if sys.version_info[:2] >= (3, 11):
37+
from asyncio import timeout
38+
else:
39+
from async_timeout import timeout
40+
41+
3642
@pytest.fixture
3743
def updater(monkeypatch, test_dir):
3844
"""Return an updater ready for testing."""

tests/integration/utils/flow_tools.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,40 @@
2222
"""
2323

2424
import asyncio
25-
from pathlib import Path
26-
from async_timeout import timeout
27-
from contextlib import asynccontextmanager, contextmanager
25+
from contextlib import (
26+
asynccontextmanager,
27+
contextmanager,
28+
)
2829
import logging
29-
import pytest
30-
from typing import Any, Optional, Union
30+
from pathlib import Path
3131
from secrets import token_hex
32+
import sys
33+
from typing import (
34+
Any,
35+
Optional,
36+
Union,
37+
)
38+
39+
import pytest
3240

3341
from cylc.flow import CYLC_LOG
34-
from cylc.flow.workflow_files import WorkflowFiles
35-
from cylc.flow.scheduler import Scheduler, SchedulerStop
42+
from cylc.flow.scheduler import (
43+
Scheduler,
44+
SchedulerStop,
45+
)
3646
from cylc.flow.scheduler_cli import RunOptions
47+
from cylc.flow.workflow_files import WorkflowFiles
3748
from cylc.flow.workflow_status import StopMode
3849

3950
from .flow_writer import flow_config_str
4051

4152

53+
if sys.version_info[:2] >= (3, 11):
54+
from asyncio import timeout
55+
else:
56+
from async_timeout import timeout
57+
58+
4259
def _make_src_flow(src_path, conf, filename=WorkflowFiles.FLOW_FILE):
4360
"""Construct a workflow on the filesystem"""
4461
flow_src_dir = (src_path / token_hex(4))

0 commit comments

Comments
 (0)