{"record":{"id":"517e4b91a2c33f54","repo":"nautechsystems/nautilus_trader","slug":"python-on-resume-failed-e-517e4b","errorCode":null,"errorMessage":"Python on_resume failed: {e}","messagePattern":"Python on_resume failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/python/actor.rs","lineNumber":1030,"sourceCode":"        }\n    });\n    msgbus::register_any(endpoint.into(), handler);\n}\n\nimpl DataActor for PyDataActorInner {\n    fn on_start(&mut self) -> anyhow::Result<()> {\n        self.dispatch_on_start()\n            .map_err(|e| anyhow::anyhow!(\"Python on_start failed: {e}\"))\n    }\n\n    fn on_stop(&mut self) -> anyhow::Result<()> {\n        self.dispatch_on_stop()\n            .map_err(|e| anyhow::anyhow!(\"Python on_stop failed: {e}\"))\n    }\n\n    fn on_resume(&mut self) -> anyhow::Result<()> {\n        self.dispatch_on_resume()\n            .map_err(|e| anyhow::anyhow!(\"Python on_resume failed: {e}\"))\n    }\n\n    fn on_reset(&mut self) -> anyhow::Result<()> {\n        self.dispatch_on_reset()\n            .map_err(|e| anyhow::anyhow!(\"Python on_reset failed: {e}\"))\n    }\n\n    fn on_dispose(&mut self) -> anyhow::Result<()> {\n        self.dispatch_on_dispose()\n            .map_err(|e| anyhow::anyhow!(\"Python on_dispose failed: {e}\"))\n    }\n\n    fn on_degrade(&mut self) -> anyhow::Result<()> {\n        self.dispatch_on_degrade()\n            .map_err(|e| anyhow::anyhow!(\"Python on_degrade failed: {e}\"))\n    }\n\n    fn on_fault(&mut self) -> anyhow::Result<()> {","sourceCodeStart":1012,"sourceCodeEnd":1048,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/python/actor.rs#L1012-L1048","documentation":"Raised by the Rust `DataActor` bridge when the Python actor's `on_resume()` callback throws an exception. `dispatch_on_resume()` propagates the Python error and `map_err` rewraps it with this message. It fires when the engine resumes a previously degraded or stopped component and delegates to user Python code.","triggerScenarios":"Calling `actor.resume()` / trading-node resume flow where the user's Python `on_resume` raises: re-subscribing to data feeds with an invalid config, using state that was never initialized, or any runtime exception in the callback body.","commonSituations":"Recovery after degradation in live trading where on_resume reconnects to a venue and the connection call raises; resuming after on_reset cleared state that on_resume assumes exists.","solutions":["Inspect the Python traceback contained in the error message to locate the raising line in on_resume.","Wrap risky re-subscription/reconnection logic in on_resume with try/except and log-and-handle.","Ensure any state on_resume reads is initialized in on_start/on_init so resume after reset works.","Test the degrade->resume cycle locally before running it live."],"exampleFix":"// before (Python)\ndef on_resume(self):\n    self.subscribe_bars(self.bar_type)\n\n// after\ndef on_resume(self):\n    try:\n        self.subscribe_bars(self.bar_type)\n    except Exception as e:\n        self.log.error(f\"resubscribe failed: {e}\")","handlingStrategy":"try-catch","validationCode":"# before resuming, check prerequisites\nassert getattr(self, 'bar_type', None) is not None, 'bar_type must be set before resume'","typeGuard":"def can_resume(actor):\n    return callable(getattr(actor, 'on_resume', None)) and getattr(actor, 'initialized', False)","tryCatchPattern":"def on_resume(self):\n    try:\n        ...  # resubscribe/reconnect\n    except Exception as e:\n        self.log.error(f\"on_resume failed: {e}\")","preventionTips":["Initialize all state on_resume depends on in on_start or __init__.","Test the full degrade/stop -> resume cycle before deploying.","Keep reconnection logic retryable instead of raising on first failure.","Log and continue on partial resubscription failures."],"tags":["python","actor-lifecycle","callback-exception","rust-bridge"],"backgroundTag":"python-callback-raised-exception","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}