summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/tasks.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-09-04 17:54:50 (GMT)
committerGitHub <noreply@github.com>2021-09-04 17:54:50 (GMT)
commitc967bd523caabb05bf5988449487d7c1717f3ac6 (patch)
tree9285bd67b942ee453f0d007130c2a1f45706a927 /Lib/asyncio/tasks.py
parentce83e42437b8e5a4bf4237f981a7a90401922456 (diff)
downloadcpython-c967bd523caabb05bf5988449487d7c1717f3ac6.zip
cpython-c967bd523caabb05bf5988449487d7c1717f3ac6.tar.gz
cpython-c967bd523caabb05bf5988449487d7c1717f3ac6.tar.bz2
[3.9] bpo-45097: Remove incorrect deprecation warnings in asyncio. (GH-28153)
Deprecation warnings about the loop argument were incorrectly emitted in cases when the loop argument was used inside the asyncio library, not from user code.
Diffstat (limited to 'Lib/asyncio/tasks.py')
-rw-r--r--Lib/asyncio/tasks.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index d7e0575..22ed328 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -580,15 +580,16 @@ def as_completed(fs, *, loop=None, timeout=None):
if futures.isfuture(fs) or coroutines.iscoroutine(fs):
raise TypeError(f"expect an iterable of futures, not {type(fs).__name__}")
+ if loop is not None:
+ warnings.warn("The loop argument is deprecated since Python 3.8, "
+ "and scheduled for removal in Python 3.10.",
+ DeprecationWarning, stacklevel=2)
+
from .queues import Queue # Import here to avoid circular import problem.
done = Queue(loop=loop)
if loop is None:
loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
todo = {ensure_future(f, loop=loop) for f in set(fs)}
timeout_handle = None
@@ -756,6 +757,10 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
"and scheduled for removal in Python 3.10.",
DeprecationWarning, stacklevel=2)
+ return _gather(*coros_or_futures, loop=loop, return_exceptions=return_exceptions)
+
+
+def _gather(*coros_or_futures, loop=None, return_exceptions=False):
if not coros_or_futures:
if loop is None:
loop = events.get_event_loop()