Skip to content

Commit d5c21f3

Browse files
Mimic asyncio.Timeout behavior (#422)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a1111c2 commit d5c21f3

File tree

5 files changed

+279
-171
lines changed

5 files changed

+279
-171
lines changed

.mypy.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[mypy]
2-
files = async_timeout, tests
2+
files = async_timeout
33
check_untyped_defs = True
44
follow_imports_for_stubs = True
55
disallow_any_decorated = True

CHANGES/422.feature.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make ``asyncio_timeout`` fully compatible with the standard ``asyncio.Timeout`` but keep backward compatibility with existing ``asyncio_timeout.Timeout`` API.

README.rst

+8-11
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,18 @@ asyncio-compatible timeout context manager.
1717
DEPRECATED
1818
----------
1919

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

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

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

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

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

3633
Usage example
3734
-------------

0 commit comments

Comments
 (0)