Skip to content

Add graceful shutdown and cancellation for actors and background tasks #236

Description

@artrixdotdev

Problem

A full TUI needs deterministic shutdown. Some background tasks and actor children are killed directly or spawned without a public cancellation/shutdown surface.

Relevant code:

  • Torrent actor stop kills peers/trackers/store/scheduler: crates/libtortillas/src/torrent/actor.rs:572
  • UDP server starts an unmanaged receiver task: crates/libtortillas/src/tracker/udp.rs:403
  • Swarm peer connections use tokio::spawn: crates/libtortillas/src/torrent/swarm.rs:30

Dependencies

Blocked by #225 for public lifecycle semantics.
Blocked by #232 because engine startup/shutdown should both be explicit frontend-visible phases.

Acceptance criteria

  • Engine shutdown stops torrents, trackers, peers, schedulers, UDP receiver tasks, and outstanding connection tasks.
  • Shutdown is awaitable and returns typed errors for failures/timeouts.
  • Repeated shutdown calls are safe.
  • No task leaks are expected after shutdown.
  • Tests cover graceful shutdown of an engine with at least one torrent actor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthigh prioGET DONE ASAP!!libtortillasChanges in the libtortillas craterustPull requests that update rust codetui-foundationWork needed before building the Tortillas TUI

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions