Skip to content

Commit

Permalink
Mimic asyncio.Timeout behavior (#422)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
asvetlov and pre-commit-ci[bot] authored Oct 31, 2024
1 parent a1111c2 commit d5c21f3
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
files = async_timeout, tests
files = async_timeout
check_untyped_defs = True
follow_imports_for_stubs = True
disallow_any_decorated = True
Expand Down
1 change: 1 addition & 0 deletions CHANGES/422.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make ``asyncio_timeout`` fully compatible with the standard ``asyncio.Timeout`` but keep backward compatibility with existing ``asyncio_timeout.Timeout`` API.
19 changes: 8 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ asyncio-compatible timeout context manager.
DEPRECATED
----------

This library has effectively been upstreamed into Python 3.11+. Therefore this library
is considered deprecated and no longer supported. We'll keep the project open in the
unlikely case of security issues until Python 3.10 is officially unsupported.
This library has effectively been upstreamed into Python 3.11+.

To migrate a project that needs to support multiple Python versions, we suggest
using this code (used in our other projects, such as aiohttp)::
Therefore this library is considered deprecated and no longer actively supported.

if sys.version_info >= (3, 11):
import asyncio as async_timeout
else:
import async_timeout
Version 5.0+ provides dual-mode when executed on Python 3.11+:
``asyncio_timeout.Timeout`` is fully compatible with ``asyncio.Timeout`` *and* old
versions of the library.

Then in your dependencies, use::
Anyway, using upstream is highly recommended. ``asyncio_timeout`` exists only for the
sake of backward compatibility, easy supporting both old and new Python by the same
code, and easy misgration.

async-timeout >= 4; python_version < "3.11"

Usage example
-------------
Expand Down
Loading

0 comments on commit d5c21f3

Please sign in to comment.