nautechsystems/nautilus_trader · error

Python on_resume failed: {e}

Error message

Python on_resume failed: {e}

What it means

The DataActor on_resume path runs Rust ExecutionAlgorithm::on_resume then dispatches the Python `on_resume` callback; Python-side exceptions are re-wrapped with this message. It signals the Python component failed when resuming from a degraded/stopped state.

Source

Thrown at crates/trading/src/python/algorithm.rs:559

}

impl DataActor for PyExecutionAlgorithm {
    fn on_start(&mut self) -> anyhow::Result<()> {
        ExecutionAlgorithm::on_start(self)?;
        self.dispatch_no_args("on_start")
            .map_err(|e| anyhow::anyhow!("Python on_start failed: {e}"))
    }

    fn on_stop(&mut self) -> anyhow::Result<()> {
        ExecutionAlgorithm::on_stop(self)?;
        self.dispatch_no_args("on_stop")
            .map_err(|e| anyhow::anyhow!("Python on_stop failed: {e}"))
    }

    fn on_resume(&mut self) -> anyhow::Result<()> {
        ExecutionAlgorithm::on_resume(self)?;
        self.dispatch_no_args("on_resume")
            .map_err(|e| anyhow::anyhow!("Python on_resume failed: {e}"))
    }

    fn on_reset(&mut self) -> anyhow::Result<()> {
        ExecutionAlgorithm::on_reset(self)?;
        self.dispatch_no_args("on_reset")
            .map_err(|e| anyhow::anyhow!("Python on_reset failed: {e}"))
    }

    fn on_dispose(&mut self) -> anyhow::Result<()> {
        self.dispatch_no_args("on_dispose")
            .map_err(|e| anyhow::anyhow!("Python on_dispose failed: {e}"))
    }

    fn on_degrade(&mut self) -> anyhow::Result<()> {
        self.dispatch_no_args("on_degrade")
            .map_err(|e| anyhow::anyhow!("Python on_degrade failed: {e}"))
    }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Read the chained `{e}` traceback and fix the Python on_resume implementation.
  2. Re-establish/revalidate connections inside on_resume rather than reusing handles captured earlier.
  3. Verify the exact method name and zero-arg signature (`def on_resume(self)`).
  4. Ensure on_start/on_reset left state consistent so resume is possible.

Example fix

// before
def on_resume(self, reason): ...  # extra arg

// after
def on_resume(self): ...
Defensive patterns

Strategy: try-catch

Validate before calling

# Python: verify resume prerequisites
assert self.degraded or self.started, "on_resume called outside degraded/stopped state"

Try / catch

if let Err(e) = actor.on_resume() {
    log::error!("python on_resume failed: {e:#}");
    // re-degrade or fault the actor rather than assuming it resumed
}

Prevention

When it happens

Trigger: Calling on_resume when the Python on_resume raises — e.g. reconnection logic fails, or the callback signature/state is wrong for the no-arg dispatch.

Common situations: Resume after degradation where upstream services are still unavailable; stale cached handles that died while degraded; missing on_resume override spelled incorrectly (e.g. onresume).

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/fc25854c3dc67fce. Report an issue: GitHub.