Skip to content

Commit

Permalink
Add async delete function in base_agent (#1800)
Browse files Browse the repository at this point in the history
Signed-off-by: Future Outlier <[email protected]>
Co-authored-by: Future Outlier <[email protected]>
  • Loading branch information
Future-Outlier and Future Outlier authored Aug 19, 2023
1 parent 6acc97b commit b49867a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions flytekit/extend/backend/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def execute(self, **kwargs) -> typing.Any:
res = asyncio.run(agent.async_create(dummy_context, output_prefix, cp_entity.template, inputs))
else:
res = agent.create(dummy_context, output_prefix, cp_entity.template, inputs)
signal.signal(signal.SIGINT, partial(self.signal_handler, agent, dummy_context, res.resource_meta))
signal.signal(signal.SIGINT, partial(self.signal_handler, agent, dummy_context, res.resource_meta))
state = RUNNING
metadata = res.resource_meta
progress = Progress(transient=True)
Expand Down Expand Up @@ -211,5 +211,8 @@ def signal_handler(
signum: int,
frame: FrameType,
) -> typing.Any:
agent.delete(context, resource_meta)
if agent.asynchronous:
asyncio.run(agent.async_delete(context, resource_meta))
else:
agent.delete(context, resource_meta)
sys.exit(1)

0 comments on commit b49867a

Please sign in to comment.