From ed64b50d11c28df62c70dcc98811c69940175ece Mon Sep 17 00:00:00 2001 From: Rohith Pariki Date: Tue, 4 Aug 2026 23:31:47 +0530 Subject: [PATCH] debt: remove async-timeout in favor of asyncio.timeout --- pyproject.toml | 6 ++---- src/crawlee/_utils/time.py | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 63a0901b8e..b70846991b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,12 @@ authors = [{ name = "Apify Technologies s.r.o.", email = "support@apify.com" }] license = "Apache-2.0" license-files = ["LICENSE"] readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.11" classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", @@ -34,7 +33,6 @@ keywords = [ "scraping", ] dependencies = [ - "async-timeout>=5.0.1", "cachetools>=5.5.0", "colorama>=0.4.0", "impit>=0.8.0", @@ -280,7 +278,7 @@ filterwarnings = [ ] [tool.ty.environment] -python-version = "3.10" +python-version = "3.11" [tool.ty.src] include = ["src", "tests", "scripts", "docs", "website"] diff --git a/src/crawlee/_utils/time.py b/src/crawlee/_utils/time.py index 10d6fd3d8d..e9ff520d8c 100644 --- a/src/crawlee/_utils/time.py +++ b/src/crawlee/_utils/time.py @@ -1,13 +1,12 @@ from __future__ import annotations +import asyncio import time from contextlib import contextmanager from dataclasses import dataclass from datetime import timedelta from typing import TYPE_CHECKING -from async_timeout import Timeout, timeout - if TYPE_CHECKING: from collections.abc import Iterator from types import TracebackType @@ -46,7 +45,7 @@ class SharedTimeout: def __init__(self, timeout: timedelta) -> None: self._remaining_timeout = timeout - self._active_timeout: Timeout | None = None + self._active_timeout: asyncio.Timeout | None = None self._activation_timestamp: float | None = None async def __aenter__(self) -> timedelta: @@ -54,7 +53,7 @@ async def __aenter__(self) -> timedelta: raise RuntimeError('A shared timeout context cannot be entered twice at the same time') self._activation_timestamp = time.monotonic() - self._active_timeout = new_timeout = timeout(self._remaining_timeout.total_seconds()) + self._active_timeout = new_timeout = asyncio.timeout(self._remaining_timeout.total_seconds()) await new_timeout.__aenter__() return self._remaining_timeout