Skip to content

Add capability to exit tasks from trigger #31718

@dstandish

Description

@dstandish

Description

We should be able to exit the "task" from the trigger.

We can already log from triggers so that's one hurdle out of the way.

The remaining hurdle I think is xcom, given that triggers run in asyncio.

One solution that comes to mind is add a queue listener running in a thread that processes the “messages” and handles submitting to xcom.

Another would be use sqlalchemy's asyncio support.

Sqlalchemy asyncio support would not help us though with custom xcom backend -- so maybe we either do just listener or we add an "optimized" path when not using custom xcom backend.

One implementation question is... would you just make it so that the trigger must call Trigger.xcom_push manually (which sends to this queue listener) or would you also want to make it possible, perhaps in an analogy with execute , possible to send the xcom payload(s) in the trigger event, or perhaps through a dedicated Trigger.success method?

I think that I’d probably prefer forcing Trigger writers to do the xcom push manually because … an interface to handle both the default return_value as well as handling multiple key-values isn’t quickly coming to mind.

cc: @jedcunningham @phanikumv @vandonr-amz

Use case/motivation

This would save users money or increase cluster bandwidth because for sensor-like deferrable tasks, no task needs to get spun up just to exit.

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions