signal handler sockets error on close leaving loop in 'running' state indefinitely
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 20/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- python
- 領域
- backend, networking
研究方向
先閱讀 uvloop/loop.pyx 中 Loop._pause_signals 和 Loop.run_until_complete 附近的程式碼,接著檢查連結的 catch-exception-on-pause 修補程式。重現 bad-file-descriptor 路徑,包括重複呼叫 run_until_complete,並新增回歸測試;完成的標準是失敗後 loop 不會仍被標記為正在執行。
由索引模型根據 Issue 內容生成。
描述
- uvloop version: 0.19.0 and 0.20.0
- Python version: 3.12
- Platform: linux/aws lambda
- Can you reproduce the bug with
PYTHONASYNCIODEBUGin env?: - Does uvloop behave differently from vanilla asyncio? How?: have observed the same error on asyncio
I have not been able to come up with a reproduction for this as I think it has something to do with how aws lambda freezes and thaws lambdas.
I have an aws lambda using uvloop that handles requests with using loop.run_until_complete. I can't use uvloop.run or aysncio.run since I need client connected to that loop to still be present on the next invocation of the lambda. Occassionally we have observed errors on the lambda with the following stack trace:
[ERROR] OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
File "/my_code.py", line 302, in request_handler
self.loop.run_until_complete(_process_records())
File "uvloop/loop.pyx", line 1511, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1504, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1377, in uvloop.loop.Loop.run_forever
File "uvloop/loop.pyx", line 547, in uvloop.loop.Loop._run
File "uvloop/loop.pyx", line 348, in uvloop.loop.Loop._pause_signals
File "/root/.pyenv/versions/3.12.1/lib/python3.12/socket.py", line 504, in close
self._real_close()
File "/root/.pyenv/versions/3.12.1/lib/python3.12/socket.py", line 498, in _real_close
_ss.close(self)
Because this error happens before the loop sets it's self._running field to 0 this means on the next invocation of the lambda the call to loop.run_until_complete errors with a loop is already running error.
I think the bad file descriptor is caused by some feature of the lambda environment or it could just be some kind of random chance since we have a lot of these running and this happens on very small fraction (<0.01%).
I wrote this patch to catch and ignore the Bad file descriptor error, but don't know if that's the right thing to do in the absence of real test case. If anyone has ideas about how I could produce a test case I am happy to try them out.
- 主要語言
- Cython
- 星號
- 11.9k
- 分支
- 615
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
MagicStack/uvloop 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
MagicStack/uvloop#759 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
MagicStack/uvloop#741 · 2 個 reaction ·
-
難度 2/5 1-3 小時 新手友好度 68/100
MagicStack/uvloop#702 · 8 則留言 · 9 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 68/100
MagicStack/uvloop#763 ·
-
難度 3/5 1-2 天 新手友好度 68/100
MagicStack/uvloop#760 ·
查看 MagicStack/uvloop 的全部 Issue
相似的 Issue
-
area/sessions comp/cron comp/gateway P2 sweeper:risk-message-delivery sweeper:risk-session-state type/bug
難度 2/5 1-3 小時 新手友好度 78/100
NousResearch/hermes-agent#118863 ·
-
難度 2/5 1-3 小時 新手友好度 76/100
-
難度 2/5 1-3 小時 新手友好度 78/100
use-agent-os/agent-os#3312 ·
-
難度 2/5 1-3 小時 新手友好度 85/100
-
needs-acceptance wg/data-plane-networking
難度 2/5 1-3 小時 新手友好度 78/100
vllm-project/semantic-router#4024 · 1 則留言 ·