`asyncio.create_subprocess_exec`: cannot read `/dev/stdin`
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- backend, operating-systems
Rechercherichtung
Beginne mit dem Reproducer in test.py und vergleiche sein Verhalten mit vanilla asyncio unter Linux in Docker. Verfolge die Behandlung von subprocess stdin durch uvloop/loop.pyx, uvloop/handles/stream.pyx und uvloop/handles/handle.pyx. Als abgeschlossen gilt die Aufgabe, wenn der /dev/stdin-Subprozess unter uvloop b'test' ausgibt, ohne dass der closed-transport error auftritt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
- uvloop version:
uvloop==0.17.0 - Python version:
Python 3.10.10 - Platform:
Linux 0af9a1603f81 5.10.76-linuxkit #1 SMP Mon Nov 8 10:21:19 UTC 2021 x86_64 GNU/Linux(in a Docker container) - Can you reproduce the bug with
PYTHONASYNCIODEBUGin env?: yes - Does uvloop behave differently from vanilla asyncio? How?: yes. Vanilla
asynciohad a similar issue patched: https://github.com/python/cpython/issues/90522
Processes run with asyncio.create_subprocess_exec fail to read from /dev/stdin with uvloop but not with asyncio
asyncio had a similar issue fixed recently (in January 2022): https://github.com/python/cpython/issues/90522
This was backported to 3.10 and 3.11
I can reproduce this on Linux in a Docker container, with either Mac OS or Linux as hosts
I cannot reproduce this on Mac OS (seems to work fine)
Logs:
# PYTHONASYNCIODEBUG=1 python test.py
cat: /dev/stdin: No such device or address
Traceback (most recent call last):
File "//test.py", line 16, in <module>
asyncio.run(f())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "//test.py", line 13, in f
stdout, _ = await proc.communicate("test".encode("utf-8"))
File "/usr/local/lib/python3.10/asyncio/subprocess.py", line 195, in communicate
stdin, stdout, stderr = await tasks.gather(stdin, stdout, stderr)
File "/usr/local/lib/python3.10/asyncio/subprocess.py", line 147, in _feed_stdin
self.stdin.write(input)
File "/usr/local/lib/python3.10/asyncio/streams.py", line 325, in write
self._transport.write(data)
File "uvloop/handles/stream.pyx", line 674, in uvloop.loop.UVStream.write
File "uvloop/handles/handle.pyx", line 159, in uvloop.loop.UVHandle._ensure_alive
RuntimeError: unable to perform operation on <WriteUnixTransport closed=True reading=False 0x7f64e3186dc0>; the handler is closed
Expected (using asyncio):
# PYTHONASYNCIODEBUG=1 python test.py
b'test'
Code to reproduce:
import asyncio
# Commenting out `uvloop` below fixes the issue
import uvloop
uvloop.install()
async def f():
proc = await asyncio.create_subprocess_exec(
"cat",
"/dev/stdin",
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
)
stdout, _ = await proc.communicate("test".encode("utf-8"))
print(stdout)
asyncio.run(f())
- Vorherrschende Sprache
- Cython
- Sterne
- 11.9k
- Forks
- 615
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus MagicStack/uvloop
-
License not clear Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
MagicStack/uvloop#759 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
MagicStack/uvloop#741 · 2 Reaktionen ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
MagicStack/uvloop#702 · 8 Kommentare · 9 Reaktionen ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
MagicStack/uvloop#766 ·
-
Directly constructed subprocess pipe protocols segfault when callbacks use a non-process owner Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
MagicStack/uvloop#765 ·
Alle Issues in MagicStack/uvloop
Ähnliche Issues
-
bug CLI custom-model
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
bug confirmed issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
open-webui/open-webui#30750 · 1 Kommentar ·
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
danielmiessler/LifeOS#2234 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100