AsyncioBackend: DeprecationWarning for StreamReader/StreamWriter in Py3.8
See original GitHub issuePython 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:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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?