pub const DEDUP_CANCELLED_SENTINEL: &str = "\x00CANCELLED";Expand description
ยงBehavior on Drop
When a DeduplicationToken is dropped without calling complete(), the
following sequence occurs:
-
Cancellation signal: The
Dropimpl sends a sentinel cancellation string ("\x00CANCELLED") over the broadcast channel before removing the entry. Any tasks already blocked inwait_for_result()receive this value viarx.recv()and returnSome("\x00CANCELLED")rather thanNone. Callers ofwait_for_resultthat inspect the returned string can detect cancellation by checking for this sentinel. -
Entry removal: After the cancellation broadcast the
InProgressentry is removed from the shared map. This drops theSender, closing the broadcast channel. Any tasks that subscribe after the removal will find no entry andwait_for_resultwill returnNone. -
Re-registrability: Because the entry is removed, the next caller to invoke
check_and_registerfor the same key will receive a freshNewtoken and can retry processing.
Waiters are NOT left hanging indefinitely. They either receive the
cancellation sentinel or None (if they race with the removal), both of
which are finite outcomes that unblock the awaiting task promptly.
The sentinel value "\x00CANCELLED" uses a NUL prefix which cannot appear
in normal LLM output, making it safe to use as a reserved signal.