Skip to content

Commit

Permalink
Deprecated loop argument to timeout().
Browse files Browse the repository at this point in the history
  • Loading branch information
carltongibson committed Dec 15, 2022
1 parent a76afc4 commit 42bf0eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.txt
@@ -1,6 +1,11 @@
UNRELEASED
----------

* The ``loop`` argument to ``asgiref.timeout.timeout`` is deprecated. As per other
``asyncio`` based APIs, the running event loop is used by default. Note that
``asyncio`` provides timeout utilities from Python 3.11, and these should be
preferred where available.

* Support for the ``ASGI_THREADS`` environment variable, used by
``SyncToAsync``, is removed. In general, a running event-loop is not
available to `asgiref` at import time, and so the default thread pool
Expand Down
5 changes: 5 additions & 0 deletions asgiref/timeout.py
Expand Up @@ -7,6 +7,7 @@


import asyncio
import warnings
from types import TracebackType
from typing import Any # noqa
from typing import Optional, Type
Expand Down Expand Up @@ -36,6 +37,10 @@ def __init__(
self._timeout = timeout
if loop is None:
loop = asyncio.get_running_loop()
else:
warnings.warn(
"""The loop argument to timeout() is deprecated.""", DeprecationWarning
)
self._loop = loop
self._task = None # type: Optional[asyncio.Task[Any]]
self._cancelled = False
Expand Down

0 comments on commit 42bf0eb

Please sign in to comment.