Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions Lib/asyncio/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


async def open_connection(host=None, port=None, *,
loop=None, limit=_DEFAULT_LIMIT, **kwds):
limit=_DEFAULT_LIMIT, **kwds):
"""A wrapper for create_connection() returning a (reader, writer) pair.

The reader returned is a StreamReader instance; the writer is a
Expand All @@ -41,12 +41,7 @@ async def open_connection(host=None, port=None, *,
StreamReaderProtocol classes, just copy the code -- there's
really nothing special here except some convenience.)
"""
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)
loop = events.get_running_loop()
reader = StreamReader(limit=limit, loop=loop)
protocol = StreamReaderProtocol(reader, loop=loop)
transport, _ = await loop.create_connection(
Expand All @@ -56,7 +51,7 @@ async def open_connection(host=None, port=None, *,


async def start_server(client_connected_cb, host=None, port=None, *,
loop=None, limit=_DEFAULT_LIMIT, **kwds):
limit=_DEFAULT_LIMIT, **kwds):
"""Start a socket server, call back for each client connected.

The first parameter, `client_connected_cb`, takes two parameters:
Expand All @@ -78,12 +73,7 @@ async def start_server(client_connected_cb, host=None, port=None, *,
The return value is the same as loop.create_server(), i.e. a
Server object which can be used to stop the service.
"""
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)
loop = events.get_running_loop()

def factory():
reader = StreamReader(limit=limit, loop=loop)
Expand All @@ -98,14 +88,10 @@ def factory():
# UNIX Domain Sockets are supported on this platform

async def open_unix_connection(path=None, *,
loop=None, limit=_DEFAULT_LIMIT, **kwds):
limit=_DEFAULT_LIMIT, **kwds):
"""Similar to `open_connection` but works with UNIX Domain Sockets."""
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)
loop = events.get_running_loop()

reader = StreamReader(limit=limit, loop=loop)
protocol = StreamReaderProtocol(reader, loop=loop)
transport, _ = await loop.create_unix_connection(
Expand All @@ -114,14 +100,9 @@ async def open_unix_connection(path=None, *,
return reader, writer

async def start_unix_server(client_connected_cb, path=None, *,
loop=None, limit=_DEFAULT_LIMIT, **kwds):
limit=_DEFAULT_LIMIT, **kwds):
"""Similar to `start_server` but works with UNIX Domain Sockets."""
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)
loop = events.get_running_loop()

def factory():
reader = StreamReader(limit=limit, loop=loop)
Expand Down
4 changes: 1 addition & 3 deletions Lib/test/test_asyncio/test_base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,7 @@ def test_create_server_stream_bittype(self):
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'no IPv6 support')
def test_create_server_ipv6(self):
async def main():
with self.assertWarns(DeprecationWarning):
srv = await asyncio.start_server(
lambda: None, '::1', 0, loop=self.loop)
srv = await asyncio.start_server(lambda: None, '::1', 0)
try:
self.assertGreater(len(srv.sockets), 0)
finally:
Expand Down
10 changes: 4 additions & 6 deletions Lib/test/test_asyncio/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ async def main(srv):
async with srv:
await srv.serve_forever()

with self.assertWarns(DeprecationWarning):
srv = self.loop.run_until_complete(asyncio.start_server(
serve, socket_helper.HOSTv4, 0, loop=self.loop, start_serving=False))
srv = self.loop.run_until_complete(asyncio.start_server(
serve, socket_helper.HOSTv4, 0, start_serving=False))

self.assertFalse(srv.is_serving())

Expand Down Expand Up @@ -102,9 +101,8 @@ async def main(srv):
await srv.serve_forever()

with test_utils.unix_socket_path() as addr:
with self.assertWarns(DeprecationWarning):
srv = self.loop.run_until_complete(asyncio.start_unix_server(
serve, addr, loop=self.loop, start_serving=False))
srv = self.loop.run_until_complete(asyncio.start_unix_server(
serve, addr, start_serving=False))

main_task = self.loop.create_task(main(srv))

Expand Down
34 changes: 14 additions & 20 deletions Lib/test/test_asyncio/test_sslproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,13 +657,11 @@ def server(sock):
sock.close()

async def client(addr):
with self.assertWarns(DeprecationWarning):
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='',
loop=self.loop,
ssl_handshake_timeout=1.0)
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='',
ssl_handshake_timeout=1.0)

with self.tcp_server(server,
max_clients=1,
Expand Down Expand Up @@ -697,13 +695,11 @@ def server(sock):
sock.close()

async def client(addr):
with self.assertWarns(DeprecationWarning):
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='',
loop=self.loop,
ssl_handshake_timeout=support.LOOPBACK_TIMEOUT)
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='',
ssl_handshake_timeout=support.LOOPBACK_TIMEOUT)

with self.tcp_server(server,
max_clients=1,
Expand Down Expand Up @@ -734,12 +730,10 @@ def server(sock):
sock.close()

async def client(addr):
with self.assertWarns(DeprecationWarning):
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='',
loop=self.loop)
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='')

self.assertEqual(await reader.readline(), b'A\n')
writer.write(b'B')
Expand Down
Loading