Fix unpicklable Boost.Python exceptions crashing ZMQ server (ESROGUE-723)#1170
Conversation
When a Boost.Python.ArgumentError is raised during a ZMQ remote procedure call, pickle.dumps() fails because Boost.Python exceptions cannot be serialized. This causes the server to crash instead of returning the error to the client. Add a fallback that converts unpicklable exceptions to a standard Exception preserving the full type name and message. Add regression test for this corner case. Resolves ESROGUE-723
There was a problem hiding this comment.
Pull request overview
This PR hardens the ZMQ RPC server against exceptions that cannot be pickled (notably Boost.Python exceptions), preventing server crashes by returning a safely-serializable fallback Exception and adding a regression test.
Changes:
- Add a fallback in
ZmqServer._doRequest()to wrap unpicklable exceptions into a plainExceptionwith a descriptive type+message string. - Add a unit test that simulates an unpicklable exception during an RPC call and verifies the server responds without crashing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
python/pyrogue/interfaces/_ZmqServer.py |
Adds nested exception-pickling fallback to avoid crashing when an exception isn’t serializable. |
tests/interfaces/test_interfaces_zmq_server.py |
Adds regression coverage for the unpicklable-exception path in _doRequest(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use getattr(exc_type, "__qualname__", exc_type.__name__) when converting unpicklable exceptions to preserve fully-qualified type names (e.g. nested classes). Also strengthen the regression test to assert the exact Exception type and verify the original exception type name appears in the converted message.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Override __reduce__ to raise PicklingError instead of relying on Boost.Python being non-importable in the test environment.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Boost.Python.ArgumentErroris raised during a ZMQ remote procedure call,pickle.dumps()fails because Boost.Python exceptions cannot be serialized, crashing the serverZmqServer._doRequest()that converts unpicklable exceptions to a standardExceptionpreserving the full type name and messageTest plan
Boost.Python.ArgumentErrorin local buildResolves ESROGUE-723