Skip to content

Commit 6d64a8f

Browse files
eamanumiss-islington
authored andcommitted
bpo-36373: Deprecate explicit loop parameter in all public asyncio APIs [streams] (GH-13671)
This PR deprecate explicit loop parameters in all public asyncio APIs This issues is split to be easier to review. Second step: streams.py https://bugs.python.org/issue36373
1 parent 949fe97 commit 6d64a8f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/asyncio/streams.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ async def open_connection(host=None, port=None, *,
175175
stacklevel=2)
176176
if loop is None:
177177
loop = events.get_event_loop()
178+
else:
179+
warnings.warn("The loop argument is deprecated since Python 3.8, "
180+
"and scheduled for removal in Python 3.10.",
181+
DeprecationWarning, stacklevel=2)
178182
reader = StreamReader(limit=limit, loop=loop)
179183
protocol = StreamReaderProtocol(reader, loop=loop, _asyncio_internal=True)
180184
transport, _ = await loop.create_connection(
@@ -213,6 +217,10 @@ async def start_server(client_connected_cb, host=None, port=None, *,
213217
stacklevel=2)
214218
if loop is None:
215219
loop = events.get_event_loop()
220+
else:
221+
warnings.warn("The loop argument is deprecated since Python 3.8, "
222+
"and scheduled for removal in Python 3.10.",
223+
DeprecationWarning, stacklevel=2)
216224

217225
def factory():
218226
reader = StreamReader(limit=limit, loop=loop)
@@ -414,6 +422,10 @@ async def open_unix_connection(path=None, *,
414422
stacklevel=2)
415423
if loop is None:
416424
loop = events.get_event_loop()
425+
else:
426+
warnings.warn("The loop argument is deprecated since Python 3.8, "
427+
"and scheduled for removal in Python 3.10.",
428+
DeprecationWarning, stacklevel=2)
417429
reader = StreamReader(limit=limit, loop=loop)
418430
protocol = StreamReaderProtocol(reader, loop=loop,
419431
_asyncio_internal=True)
@@ -473,6 +485,10 @@ async def start_unix_server(client_connected_cb, path=None, *,
473485
stacklevel=2)
474486
if loop is None:
475487
loop = events.get_event_loop()
488+
else:
489+
warnings.warn("The loop argument is deprecated since Python 3.8, "
490+
"and scheduled for removal in Python 3.10.",
491+
DeprecationWarning, stacklevel=2)
476492

477493
def factory():
478494
reader = StreamReader(limit=limit, loop=loop)

0 commit comments

Comments
 (0)