SysLogHandler closes tcp session after first message (also noted in #66006)
未關閉
還沒有人認領這個 Issue。
stdlib
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Python 3.10.5
While running FastAPI (Uvicorn) and the SysLogHandler. The Socket if using a TCP stream is being closed after the first message, causing all additional messages to fail stating OSError10083. In looking through the SysLogHandler code I was able to add a try/except that solved the issue by opening a new socket if the current is found to be closed.
Lines 990/991:
else:
self.socket.sendall(msg)
I changed to:
else:
try:
self.socket.sendall(msg)
except OSError:
with socket.create_connection(self.address) as s:
s.sendall(msg)
Your environment
Python 3.10
- CPython versions tested on: 3.10
- Operating system and architecture: Windows 10
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 SysLogHandler 約第 990-991 行附近的 TCP 傳送分支開始,使用 FastAPI 和 Uvicorn 在 Windows 10 上透過 Python 3.10 重現該故障。驗證 TCP socket 關閉後傳送多則訊息不會失敗;如果儲存庫中有相關的測試位置,則為重新連線行為新增或更新涵蓋率。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- networking, observability-sre
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100