Skip to content

chore: only depend on async-timeout below Python 3.11 - #2248

Open
enriquealonso01 wants to merge 2 commits into
apify:masterfrom
enriquealonso01:chore/drop-async-timeout
Open

enriquealonso01 wants to merge 2 commits into
apify:masterfrom
enriquealonso01:chore/drop-async-timeout

Conversation

@enriquealonso01

@enriquealonso01 enriquealonso01 commented Sep 22, 2026

Copy link
Copy Markdown

What this does

Refs #2052 (left open per maintainer — TODO when the floor bumps to 3.11) — but with a narrowing instead of a hard removal, because requires-python = ">=3.10" and stdlib asyncio.timeout only exists from 3.11.

  • pyproject.toml: async-timeout>=5.0.1 gets a python_full_version < '3.11' marker.
  • src/crawlee/_utils/time.py: SharedTimeout (the only consumer) picks timeout_ctx = asyncio.timeout on 3.11+ or the async-timeout backport otherwise, at import time. Call sites are unchanged; the Timeout | None annotation stays honest via asyncio.Timeout.
  • uv.lock: re-resolved; async-timeout is now 3.10-only.

Verification

  • tests/unit/_utils: 322 passed.
  • Full unit suite: 2414 passed, 1 failed — the single failure (test_firefox_headless_headers) is a missing Playwright Firefox binary in the CI-less sandbox environment and reproduces identically on clean master; it is unrelated to this change.
  • uv lock --check passes; ruff check + ruff format --check clean.
  • Live sanity: SharedTimeout on 3.11 expires and raises asyncio.TimeoutError as before.

If maintainers prefer the hard removal from the issue title, dropping the marker + the backport import is a two-line follow-up — happy to do it if you'd rather drop 3.10 support in this PR.

Closes apify#2052. asyncio.timeout is stdlib from 3.11, so on 3.11+ the
package no longer needs the backport; the dependency gains a
python_full_version < '3.11' marker instead of applying to everyone.
SharedTimeout, the only consumer, goes through a single timeout_ctx
binding picked at import time, so the call sites are unchanged.
asyncio.Timeout raises TimeoutError, a subclass of asyncio.TimeoutError,
which is what the existing tests already expect via
pytest.raises(asyncio.TimeoutError).

Verified on 3.11: tests/unit/_utils 319 passed; full unit suite 2473
passed with only 4 pre-existing failures that reproduce identically on
clean master (browser/playwright environment issues, unrelated). ruff
check and format clean. uv lock re-resolved: async-timeout is now
3.10-only.

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @enriquealonso01, thank you for your contribution. But please don't close the issue #2052, save it for TODO

Comment thread src/crawlee/_utils/time.py Outdated
else:
# async-timeout backports asyncio.timeout for Python 3.10; drop once the
# project floor is 3.11 (its Timeout also raises TimeoutError, a subclass
# of asyncio.TimeoutError, on expiry).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# of asyncio.TimeoutError, on expiry).
# TODO: `async-timeout` backports `asyncio.timeout` for Python 3.10; drop once the
# project floor bump to 3.11
# https://github.com/apify/crawlee-python/issues/2052

@enriquealonso01

Copy link
Copy Markdown
Author

Done — applied your suggestion verbatim (TODO comment linking #2052), and updated the PR body from 'Closes' to 'Refs' so the issue stays open for the 3.11 floor bump. Pushed as 395fa9c.

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants