Repository navigation
Fix PingPortListener reply on Python 3 (thread exits on first connection) - #4267
Open
DicksonWu654 wants to merge 1 commit into
Open
DicksonWu654 wants to merge 1 commit into
DicksonWu654 wants to merge 1 commit into
Conversation
conn.send("OK") raises TypeError on Python 3, the handler logs it and
calls sys.exit(1), so the ping listener thread ends on its first
connection and the port stops answering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
PingPortListener.runcallsconn.send("OK"). On Python 3socket.sendneeds bytes, so it raisesTypeError. The except branch logs "a bytes-like object is required, not 'str'" and callssys.exit(1), which ends the listener thread. So the first connection to the ping port gets an empty reply, the thread exits, and every later connection hangs until it times out. The agent process itself keeps running.This changes the reply to
b"OK".How was this patch tested?
I ran the real
PingPortListenerclass from trunk (445e0bc) under Python 3.12 on 127.0.0.1, withping_port=0and the fuser check stubbed out, and opened three connections:b''and the thread is dead; the next two time outb"OK"and the thread stays aliveI haven't run the full agent test suite. I didn't open a JIRA for this - happy to if you'd like one for the title.