Fix KeyError in SocketInterface.shutdown() when worker exits during wait - #1063
Conversation
shutdown() unconditionally indexed the reply dict with ["result"], but
receive_dict() returns {"error": ExecutorlibSocketError(...)} instead
when the worker process exits while shutdown() is waiting for its
reply. That race raises a KeyError inside SocketInterface.__del__,
which surfaces as a confusing "Exception ignored in ... __del__"
traceback during garbage collection even though nothing actually
crashed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesInteractive shutdown
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Interactive shutdown now handles a worker exiting during response waiting without raising a destructor traceback. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Updated test to bind to a random port and connect a peer to prevent blocking during shutdown.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1063 +/- ##
=======================================
Coverage 94.25% 94.26%
=======================================
Files 39 39
Lines 2176 2178 +2
=======================================
+ Hits 2051 2053 +2
Misses 125 125 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
SocketInterface.shutdown()unconditionally indexed the reply dict returned bysend_and_receive_dict()with["result"].receive_dict()can instead return{"error": ExecutorlibSocketError(...)}if the worker process exits whileshutdown()is waiting for its reply (a benign race - the worker simply finished/exited on its own).KeyError: 'result'insideSocketInterface.__del__, which Python cannot propagate from a destructor, so it prints a confusingException ignored in: <function SocketInterface.__del__>traceback during garbage collection (e.g. when Jupyter releases old cached objects) even though nothing actually crashed."result"key when it's present, otherwiseshutdown()returnsNonefor this benign race instead of raising.Test plan
test_interface_shutdown_with_process_exiting_during_wait, which uses a spawner whosepoll()reports the process alive only once (matching the real race window) and assertsshutdown()no longer raises.Summary by CodeRabbit