question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AsyncioBackend: DeprecationWarning for StreamReader/StreamWriter in Py3.8

See original GitHub issue

Python 3.8 builds are filled with warnings about asyncio API changes: https://travis-ci.org/encode/httpx/jobs/574559125

Looks like as as of Python 3.8, asyncio.open_connection() is deprecated in favor of asyncio.connect() — see the asyncio 3.8+ docs.

# < 3.8
reader, writer = await asyncio.open_connection('127.0.0.1', 8888)

# 3.8+
async with asyncio.connect('127.0.0.1', 8888) as stream:
    ...
# or:
stream = await asyncio.connect('127.0.0.1', 8888)

This is not a trivial API change, and I don’t know if there are plans to back-port asyncio.connect() to 3.7 and below.

So at first glance resolving this would need to adapt the .connect() method on AsyncioBackend to use one or the other depending on the Python version we’re running on — and also make Reader/Writer pair (and soon Stream) handle both possibilities ?

Originally raised in: https://github.com/encode/httpx/pull/255#discussion_r315904773

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
aeroscommented, Sep 29, 2019

I can confirm that we are removing the deprecation warnings for StreamReader, StreamWriter, StreamReaderProtocol, SubprocessProtocol, and Process in Python 3.8. They might be reinstated for 3.9 depending on what direction is taken with the asyncio streaming API, but they shouldn’t be present in 3.8. This applies to any of the new functions added in https://github.com/python/cpython/commit/23b4b697e5b6cc897696f9c0288c187d2d24bff2 (primary commit being reverted).

https://github.com/python/cpython/pull/16455/files is mostly just awaiting final review from the maintainers of asyncio. If Yury or Andrew have anything to add, they can directly edit the PR or open a new one if needed, but the new streaming API reversion will happen for Python 3.8 regardless of what happens with that PR.

2reactions
pquentincommented, Sep 29, 2019

It looks like asyncio is reverting the new streaming API: https://bugs.python.org/issue38242. Does that means the work from #369 is going to be irrelevant?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Streams — Python 3.11.1 documentation
Streams are high-level async/await-ready primitives to work with network connections. Streams allow sending and receiving data without using callbacks or low- ...
Read more >
asyncio: works in Python 3.10 but not in Python 3.8
As discussed in this answer, pre-python 3.10 Semaphore sets its loop on __init__ based on the current running loop, while asyncio.run starts ...
Read more >
Python AsyncIO: Asynchronous IO - Lei Mao's Log Book
It receives a (reader, writer) pair as two arguments, instances of the StreamReader and StreamWriter classes.” Therefore, the connection to the ...
Read more >
[FIXED] Python Asyncio Network Client StreamWriter does not ...
import asyncio from asyncio import StreamReader, StreamWriter, ... python3 sof_asyncio_client.py Connecting to server: 127.0.0.1 on port: ...
Read more >
8 Streams - Python Concurrency with asyncio
The designers of asyncio realized this and built network stream APIs to ... Jetands vl icyledrt tnintntiagasi StreamReader usn StreamWriter sasnecnti, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found