summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-12 12:59:50 (GMT)
committerGitHub <noreply@github.com>2019-09-12 12:59:50 (GMT)
commit345bfc990f5f3e873774051d43136b06bfed82cb (patch)
tree331c7d0dba577f1c5dca1327b142b80b1be56f8a /Lib/asyncio
parent535863e3f599a6ad829204d83f144c91e44de443 (diff)
downloadcpython-345bfc990f5f3e873774051d43136b06bfed82cb.zip
cpython-345bfc990f5f3e873774051d43136b06bfed82cb.tar.gz
cpython-345bfc990f5f3e873774051d43136b06bfed82cb.tar.bz2
bpo-36373: Deprecate explicit loop in task and subprocess API (GH-16033)
(cherry picked from commit a488879cbaf4b8b52699cadccf73bb4c271bcb29) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/subprocess.py13
-rw-r--r--Lib/asyncio/tasks.py19
2 files changed, 30 insertions, 2 deletions
diff --git a/Lib/asyncio/subprocess.py b/Lib/asyncio/subprocess.py
index e6c1c8b..ce504b8 100644
--- a/Lib/asyncio/subprocess.py
+++ b/Lib/asyncio/subprocess.py
@@ -224,6 +224,13 @@ async def create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None,
**kwds):
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
+ )
+
protocol_factory = lambda: SubprocessStreamProtocol(limit=limit,
loop=loop,
_asyncio_internal=True)
@@ -239,6 +246,12 @@ async def create_subprocess_exec(program, *args, stdin=None, stdout=None,
limit=streams._DEFAULT_LIMIT, **kwds):
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
+ )
protocol_factory = lambda: SubprocessStreamProtocol(limit=limit,
loop=loop,
_asyncio_internal=True)
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index cd4832c..a0cb884 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -573,10 +573,17 @@ def as_completed(fs, *, loop=None, timeout=None):
"""
if futures.isfuture(fs) or coroutines.iscoroutine(fs):
raise TypeError(f"expect a list of futures, not {type(fs).__name__}")
- loop = loop if loop is not None else events.get_event_loop()
- todo = {ensure_future(f, loop=loop) for f in set(fs)}
+
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
def _on_timeout():
@@ -733,6 +740,10 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
if not coros_or_futures:
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)
outer = loop.create_future()
outer.set_result([])
return outer
@@ -842,6 +853,10 @@ def shield(arg, *, loop=None):
except CancelledError:
res = None
"""
+ 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)
inner = ensure_future(arg, loop=loop)
if inner.done():
# Shortcut.