crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] Cannot properly kill a flow

Open fmatray opened this issue 7 months ago • 4 comments

Description

I have a flow with a simple crew inside. While running, if I try to fo CTRL+C to kill the process, I get an "Aborted!" and then the process follow and continue to stream to stdout.

I have to manually kill ".venv/bin/kickoff" to end the process. This does not happen with crew only projects.

Steps to Reproduce

  1. Create a flow with a crew
  2. kickoff the flow
  3. Try to abort with CTRL+C
  4. The process continues until ".venv/bin/kickoff" is killed

Expected behavior

The flow should stop :-)

Screenshots/Code snippets

Image

Operating System

Other (specify in additional context)

Python Version

3.12

crewAI Version

0.114.0

crewAI Tools Version

0.40.1

Virtual Environment

Venv

Evidence

c'est screenshot above

Possible Solution

None

Additional context

I'm on MacOS Sequoia (this version is not in the list above).

fmatray avatar Apr 15 '25 19:04 fmatray

Flows seems to be kickoff with async but not crews. So, I guess, KeyboardInterrupt is not properly captured

I found this in python doc. https://docs.python.org/3.13/library/asyncio-runner.html#handling-keyboard-interruption

fmatray avatar Apr 15 '25 19:04 fmatray

@fmatray thank your for reporting that. Just one thing to note, this feature was introduced in Python 3.11, and we currently support Python 3.10. Really appreciate if you could be able to submit a PR with a fix

lucasgomide avatar Apr 15 '25 20:04 lucasgomide

I’m sorry, I don’t have a fix. Werk you able to reproduce the issue ?

fmatray avatar Apr 16 '25 22:04 fmatray

@fmatray Yeah - recently I found the same behavior by running the SeleniumCrawerTool, btw. I tried a simple fix but didn't work. Have to dedicate more time to understand at all

lucasgomide avatar Apr 17 '25 00:04 lucasgomide

Marginally connected, but I have an agent that needs to run in in a wrapper code that has to support a graceful shutdown process. I'm intercepting SIGTERM signal to perform cleanup before the application finishes. However there seems to be no way to interrupt the crew while it's running via a method call for example. Am I missing something? Is there a recommended way to do this?

RogerVFbr avatar May 10 '25 00:05 RogerVFbr

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 09 '25 12:06 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jun 15 '25 12:06 github-actions[bot]