Skip to content

Commit

Permalink
fix: make asyncio cancellation handling compatible with 3.10 (#4303)
Browse files Browse the repository at this point in the history
Fix asyncio cancellation handling for Python 3.11 compatibility

Co-authored-by: Christophe Bornet <[email protected]>
  • Loading branch information
ogabrielluiz and cbornet authored Oct 28, 2024
1 parent 882f20d commit 924e02f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/backend/base/langflow/services/telemetry/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import os
import platform
import sys
from datetime import datetime, timezone
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -136,7 +137,10 @@ async def _cancel_task(self, task: asyncio.Task, cancel_msg: str) -> None:
await task
except asyncio.CancelledError:
current_task = asyncio.current_task()
if current_task and current_task.cancelling() > 0:
if sys.version_info >= (3, 11):
if current_task and current_task.cancelling() > 0:
raise
elif current_task and hasattr(current_task, "_must_cancel") and current_task._must_cancel:
raise

async def stop(self) -> None:
Expand Down

0 comments on commit 924e02f

Please sign in to comment.