oxidecomputer / async-bb8-diesel

Safe asynchronous access to Diesel and the bb8 connection manager
MIT License
12 stars 8 forks source link

[RFC] handle runtime shutdowns while tasks are being spawned #79

Closed sunshowers closed 1 week ago

sunshowers commented 1 week ago

If a runtime has been marked as shutting down before spawn_blocking is called, or before the blocking task is first scheduled, the JoinHandle will return a cancellation error. Currently, this panics, which tends to manifest as test failures.

Instead, add a RunError wrapper that captures the cancellation situation. Callers might choose to bubble this error up or to squelch it -- unfortunately, we can't make this decision.

I haven't written tests yet but I should be able to if this looks reasonble.

The API surface here is really unfortunate, but I can't see a better way to do this than to propagate errors up the stack.

sunshowers commented 1 week ago

Sorry, spr screwing up here.