Files
crewAI/lib/crewai/tests
Devin AI 47c698dc86 fix: implement cooperative cancellation for timeout handling
This commit fixes issue #4135 by implementing cooperative cancellation
to prevent orphaned threads and resource leaks when task execution times out.

Changes:
- Add deadline tracking to CrewAgentExecutor with set_execution_deadline(),
  clear_execution_deadline(), and _check_execution_deadline() methods
- Add deadline check at the start of each iteration in _invoke_loop() and
  _ainvoke_loop() to enable cooperative cancellation
- Update _execute_with_timeout() to set the deadline before execution and
  use shutdown(wait=False) to return control promptly after timeout
- Update _aexecute_with_timeout() to set the deadline for consistency
- Add comprehensive tests for timeout handling behavior

The fix ensures that:
1. Timeout returns control to the caller promptly
2. Worker threads exit cleanly when they check the deadline
3. Resources are properly cleaned up after timeout

Co-Authored-By: João <joao@crewai.com>
2025-12-20 15:01:11 +00:00
..
2025-10-20 14:10:19 -07:00
2025-12-04 16:53:19 -05:00
2025-12-04 12:54:49 -05:00
2025-10-20 14:10:19 -07:00
2025-10-20 14:10:19 -07:00
2025-12-04 13:34:29 -08:00
2025-12-05 13:23:26 -05:00
2025-10-20 14:10:19 -07:00
2025-10-20 14:10:19 -07:00
2025-12-01 18:56:56 -05:00
2025-12-04 17:08:08 -05:00
2025-10-20 14:10:19 -07:00
2025-10-20 14:10:19 -07:00
2025-10-20 14:10:19 -07:00