Skip to main content

try_reset_shutdown

Function try_reset_shutdown 

Source
pub fn try_reset_shutdown() -> bool
Expand description

Resets the global shutdown flag to false and zeroes the signal counters.

Returns true if the flag was previously set, false if it was already cleared. Intended for tests and audit invocations where the SHUTDOWN flag was contaminated by an earlier signal handler in the same process tree. Production code must NOT call this — the only legitimate callers are integration tests, audit scripts, and the --ignore-shutdown CLI flag.

Note: this only resets the SHUTDOWN flag. The global CancellationToken remains in its previous cancelled state because tokio_util::sync::CancellationToken is one-shot. Callers that need a resettable token must use a per-invocation token (see should_obey_shutdown) instead of relying on the global one.

§Examples

use std::sync::atomic::Ordering;
use sqlite_graphrag::{SHUTDOWN, try_reset_shutdown};

SHUTDOWN.store(true, Ordering::Release);
assert!(try_reset_shutdown());
assert!(!SHUTDOWN.load(Ordering::Acquire));