Skip to content

fix(observe): Handle asyncio.CancelledError in exception blocks#1566

Merged
hassiebp merged 2 commits intolangfuse:mainfrom
jinohkang-theori:patch-1
Mar 19, 2026
Merged

fix(observe): Handle asyncio.CancelledError in exception blocks#1566
hassiebp merged 2 commits intolangfuse:mainfrom
jinohkang-theori:patch-1

Conversation

@jinohkang-theori
Copy link
Contributor

@jinohkang-theori jinohkang-theori commented Mar 18, 2026

Fixes langfuse/langfuse#12650

This catches and records the async task being cancelled—either directly or because it timed out—which will raise an asyncio.CancelledError to stop execution.

Also fix sync wrappers as well. Note that asyncio.CancelledError can cross async-sync boundaries, such as run_coroutine_threadsafe().result() or a sync helper function that re-raises cancellation that was previously suppressed/deferred.

@jinohkang-theori jinohkang-theori force-pushed the patch-1 branch 3 times, most recently from ba4506c to a706ed4 Compare March 19, 2026 07:53
Fixes langfuse/langfuse#12650

This catches and records the async task being cancelled—either directly or
because it timed out—which will raise an asyncio.CancelledError to stop
execution.

Also fix sync wrappers as well. Note that asyncio.CancelledError can cross
async-sync boundaries, such as `run_coroutine_threadsafe().result()` or a sync
helper function that re-raises cancellation that was previously
suppressed/deferred.
@hassiebp
Copy link
Contributor

Thanks a lot for your contribution, @jinohkang-theori !

@hassiebp hassiebp merged commit 1806084 into langfuse:main Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: @observe does not record asyncio.CancelledError on Python 3.8+

2 participants