Skip to content

Commit

Permalink
Merge pull request #6558 from MetRonnie/async-timeout
Browse files Browse the repository at this point in the history
Deprecate async-timeout dependency
  • Loading branch information
oliver-sanders authored Jan 15, 2025
2 parents bbe7599 + 771298f commit 26b12e4
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 21 deletions.
2 changes: 1 addition & 1 deletion conda-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 23 additions & 4 deletions cylc/flow/network/ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,36 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

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):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions tests/integration/test_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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)
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/test_replier.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

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."""
Expand Down
10 changes: 8 additions & 2 deletions tests/integration/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable
from async_timeout import timeout
from getpass import getuser
import sys
from typing import Callable

import pytest

from cylc.flow.network.server import PB_METHOD_MAP
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)
Expand Down
8 changes: 7 additions & 1 deletion tests/integration/test_workflow_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

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',
Expand Down
8 changes: 7 additions & 1 deletion tests/integration/tui/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."""
Expand Down
31 changes: 24 additions & 7 deletions tests/integration/utils/flow_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 26b12e4

Please sign in to comment.