Fix potential stack overflow in _wait_until_complete#301
Conversation
Converts the recursive implementation to an iterative while loop. Under heavy queue load the recursion depth could grow unboundedly; the iterative form has the same behaviour with no stack risk. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the recursive _wait_until_complete method in SRT/netfunnel.py into an iterative while True loop to avoid potential recursion limit issues. The review feedback suggests adding an explicit timeout parameter to the HTTP GET request to prevent the application from hanging indefinitely during high-traffic periods.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| resp = self.session.get( | ||
| self.NETFUNNEL_URL, | ||
| params=params, | ||
| ) |
There was a problem hiding this comment.
Under high-traffic conditions (when NetFunnel is typically active), the server is more likely to experience high load, leading to dropped connections or extremely slow responses. Since requests.get has no default timeout, the call can hang indefinitely, causing the application to freeze. Adding an explicit timeout parameter prevents this.
| resp = self.session.get( | |
| self.NETFUNNEL_URL, | |
| params=params, | |
| ) | |
| resp = self.session.get( | |
| self.NETFUNNEL_URL, | |
| params=params, | |
| timeout=10, | |
| ) |
|
Well, I doubt there would be a large number of recursive calls normally. Did you ever face this situation? |
Summary
_wait_until_completecurrently calls itself recursively while waiting for the NetFunnel queue. Under sustained high-traffic conditions the queue wait can be long enough for the recursion depth to grow unboundedly, risking aRecursionError.This PR converts the implementation to an equivalent iterative
whileloop, which has identical behaviour with no stack risk.Changes
SRT/netfunnel.py: replace recursive_wait_until_completewith awhile Trueloop;keyis updated in-place each iteration instead of being passed as a new recursive argument.Test plan
chkEnter, sleeps 1 s whilenwait != 0, and returns the key once the queue clears🤖 Generated with Claude Code