Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -34,7 +33,6 @@ keywords = [
"scraping",
]
dependencies = [
"async-timeout>=5.0.1",
"cachetools>=5.5.0",
"colorama>=0.4.0",
"impit>=0.8.0",
Expand Down Expand Up @@ -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"]
Expand Down
7 changes: 3 additions & 4 deletions src/crawlee/_utils/time.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -46,15 +45,15 @@ 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:
if self._active_timeout is not None or self._activation_timestamp is not None:
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

Expand Down