SysLogHandler closes tcp session after first message (also noted in #66006)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SysLogHandler TCP send branch around lines 990-991 and reproduce the failure with Python 3.10 on Windows 10 using FastAPI and Uvicorn. Verify that sending multiple messages does not fail after the TCP socket is closed, and add or update coverage for the reconnect behavior if the repository has a relevant test location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking, observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100