GLib.Cancellable timeout configuration in Vala async methods
22.5K reputation · 18 Nov 2021, 05:47 UTC
Goal is to configure cooperative cancellation and timeouts for Vala async methods that accept GLib.Cancellable.
Vala exposes Cancellable as a first-class async parameter from GIO/GObject bindings. Timeouts are typically built with GLib.Timeout.add or GLib.Source and manually wired to Cancellable.cancel(). Cancellation is cooperative; the callee must poll cancellable.is_cancelled() or connect to the cancelled signal. There is no forced thread interruption.
Uncertainty remains about propagation decisions and version-sensitive semantics. Vala async/await does not automatically enforce a timeout, and the implementer must decide whether to propagate cancellation to underlying resources, clean up partial state, or allow background completion. GLib.Cancellable behavior and MainContext assumptions vary across GLib releases.
Should cancellation triggered by a timeout be propagated to all downstream async calls or only abort the caller? What cleanup contract is expected when cancellation occurs mid-await in the generated state machine? Is there a defined permission boundary for cancelling work running outside the default MainContext?