You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Expose FIRE_AND_FORGET task handles on PluginResult for deterministic awaiting #25
PluginExecutor._fire_and_forget_tasks() schedules background work via asyncio.create_task() but discards the resulting task handles. Callers of PluginManager.invoke_hook() have no way to know when those background tasks
complete. The only workaround today is an arbitrary asyncio.sleep(), which
is racy under load or on slow CI runners.
User Story 1
As a: developer using CPEX's FIRE_AND_FORGET plugin mode
I want: the task handles created by _fire_and_forget_tasks() to be accessible on PluginResult
So that: I can deterministically await background task completion in tests and other sync-sensitive contexts
Acceptance Criteria
Scenario: Caller awaits background tasks after hook invocationGiven a hook with one or more FIRE_AND_FORGET plugins registered
When invoke_hook() returns a PluginResult
Then result.background_tasks contains the asyncio.Task handles created for those plugins
Scenario: Callers that ignore background_tasks see no behavior changeGiven a hook invocation with no caller reading background_tasks
When invoke_hook() completes
Then fire-and-forget tasks still run in the background as before
Populate it in _fire_and_forget_tasks() by collecting the return values of asyncio.create_task(). Callers that need a deterministic sync point can then:
Test-only asyncio.create_task patch — monkey-patching asyncio in tests; messy and global.
Additional Context
Surfaced while writing deterministic tests for telemetry plugins in a downstream
project that uses CPEX's FIRE_AND_FORGET mode. See: generative-computing/mellea#691
Activity
[-][FEATURE]:[/-][+][FEATURE]: Expose FIRE_AND_FORGET task handles on PluginResult for deterministic awaiting[/+]araujof commentedon Apr 21, 2026
Thanks for this feature request @ajbozarth ! Would you like to contribute a PR?
ajbozarth commentedon Apr 21, 2026
Sure I can contribute a PR