`asyncio.create_subprocess_exec`: cannot read `/dev/stdin`
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 45/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
從 test.py 中的 reproducer 開始,並在 Docker 中的 Linux 上將其行為與 vanilla asyncio 進行比較。追蹤 subprocess 的 stdin 處理流程,檢查 uvloop/loop.pyx、uvloop/handles/stream.pyx 和 uvloop/handles/handle.pyx。完成的標準是:/dev/stdin 子程序在 uvloop 下輸出 b'test',且不出現 closed-transport error。
由索引模型根據 Issue 內容生成。
描述
- 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())
- 主要語言
- Cython
- 星號
- 11.9k
- 分支
- 615
- 平均合併
- 4 小時 43 分鐘
- 30 天內合併 PR
- 3
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
MagicStack/uvloop 的其他 Issue
-
uv 1.53.0 fix可能已有人在做 @fantix 於 3 天前認領。 未關閉
難度 1/5 1 小時以內 新手友好度 85/100
MagicStack/uvloop#774 · 1 則留言 · 1 個 reaction ·
-
難度 2/5 1-3 小時 新手友好度 68/100
MagicStack/uvloop#759 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
MagicStack/uvloop#741 · 2 個 reaction ·
-
`asyncio.get_event_loop` raises error instead of spawning new loop when no loop is running.可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
MagicStack/uvloop#702 · 8 則留言 · 9 個 reaction ·
-
難度 5/5 一週以上 新手友好度 25/100
MagicStack/uvloop#773 ·
查看 MagicStack/uvloop 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
zerocracy/judges-action#2739 ·
維護者通常 8 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
-
[Bug] The producer summary counts an unreported client version as a second version and warns about a version mix可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
apache/rocketmq-dashboard#6110 ·
維護者通常 4 天內回覆
-
area:core bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
area/install-update comp/gateway P0 sweeper:risk-compatibility type/bug
難度 2/5 1 小時以內 新手友好度 72/100
NousResearch/hermes-agent#135997 · 3 則留言 ·
維護者通常 1 天內回覆