From 4c628e4ffaad353274bb0aff38ead9f1a2d58e81 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 9 Dec 2025 14:29:43 +0530 Subject: [PATCH] fix: replace bare except with specific exceptions in async queue The bare except: block in AsyncQueue.wait() could catch critical system exceptions like KeyboardInterrupt and SystemExit, masking important signals. This change specifies exact exception types: - asyncio.CancelledError: Expected cancellation during await - Exception: Application-level exceptions This follows Python best practices (PEP 8) and prevents accidentally suppressing system-level exceptions that should propagate. --- libs/langgraph/langgraph/_internal/_queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langgraph/langgraph/_internal/_queue.py b/libs/langgraph/langgraph/_internal/_queue.py index a7e48c486b..1be136c48f 100644 --- a/libs/langgraph/langgraph/_internal/_queue.py +++ b/libs/langgraph/langgraph/_internal/_queue.py @@ -25,7 +25,7 @@ async def wait(self) -> None: self._getters.append(getter) try: await getter - except: + except (asyncio.CancelledError, Exception): getter.cancel() # Just in case getter is not done yet. try: # Clean self._getters from canceled getters.