Skip to content

Commit 9cb7a84

Browse files
committed
refactor: replace async-timeout with asyncio.timeout (#2314)
Drops the `async-timeout` dependency. `SharedTimeout` was its only user and now uses `asyncio.timeout` from the standard library, which is available since Python 3.11. Closes: #2052 *✍️ Drafted by Claude Code*
1 parent 4a24c10 commit 9cb7a84

3 files changed

Lines changed: 3 additions & 7 deletions

File tree

‎pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ keywords = [
3434
"scraping",
3535
]
3636
dependencies = [
37-
"async-timeout>=5.0.1",
3837
"cachetools>=5.5.0",
3938
"colorama>=0.4.0",
4039
"impit>=0.13.2",

‎src/crawlee/_utils/time.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from __future__ import annotations
22

3+
import asyncio
34
import time
45
from contextlib import contextmanager
56
from dataclasses import dataclass
67
from datetime import timedelta
78
from typing import TYPE_CHECKING
89

9-
from async_timeout import Timeout, timeout
10-
1110
if TYPE_CHECKING:
1211
from collections.abc import Generator
1312
from types import TracebackType
@@ -46,15 +45,15 @@ class SharedTimeout:
4645

4746
def __init__(self, timeout: timedelta) -> None:
4847
self._remaining_timeout = timeout
49-
self._active_timeout: Timeout | None = None
48+
self._active_timeout: asyncio.Timeout | None = None
5049
self._activation_timestamp: float | None = None
5150

5251
async def __aenter__(self) -> timedelta:
5352
if self._active_timeout is not None or self._activation_timestamp is not None:
5453
raise RuntimeError('A shared timeout context cannot be entered twice at the same time')
5554

5655
self._activation_timestamp = time.monotonic()
57-
self._active_timeout = new_timeout = timeout(self._remaining_timeout.total_seconds())
56+
self._active_timeout = new_timeout = asyncio.timeout(self._remaining_timeout.total_seconds())
5857
await new_timeout.__aenter__()
5958
return self._remaining_timeout
6059

‎uv.lock‎

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)