From c9d9d7c2dc6e8077ea048261e46e6a8264da4ef0 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Mon, 18 Nov 2024 10:25:46 -0800 Subject: [PATCH] PYTHON-4907 Avoid noisy TypeError at interpreter exit (#2005) --- pymongo/asynchronous/mongo_client.py | 3 ++- pymongo/synchronous/mongo_client.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pymongo/asynchronous/mongo_client.py b/pymongo/asynchronous/mongo_client.py index e4fdf25c2..3e4dc482d 100644 --- a/pymongo/asynchronous/mongo_client.py +++ b/pymongo/asynchronous/mongo_client.py @@ -1195,7 +1195,8 @@ class AsyncMongoClient(common.BaseObject, Generic[_DocumentType]): ResourceWarning, stacklevel=2, ) - except AttributeError: + except (AttributeError, TypeError): + # Ignore errors at interpreter exit. pass def _close_cursor_soon( diff --git a/pymongo/synchronous/mongo_client.py b/pymongo/synchronous/mongo_client.py index 0380d4468..00c6203a9 100644 --- a/pymongo/synchronous/mongo_client.py +++ b/pymongo/synchronous/mongo_client.py @@ -1193,7 +1193,8 @@ class MongoClient(common.BaseObject, Generic[_DocumentType]): ResourceWarning, stacklevel=2, ) - except AttributeError: + except (AttributeError, TypeError): + # Ignore errors at interpreter exit. pass def _close_cursor_soon(