Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pymongo/asynchronous/mongo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2752,8 +2752,10 @@ async def __aexit__(
try:
await self.handle(exc_type, exc_val)
finally:
if self._pool_checkout is not None:
await self._pool_checkout.__aexit__(exc_type, exc_val, exc_tb)
pool_checkout = self._pool_checkout
self._pool_checkout = None # to break the reference cycle before cleanup can raise
if pool_checkout is not None:
await pool_checkout.__aexit__(exc_type, exc_val, exc_tb)

@classmethod
def for_existing_conn(
Expand Down
6 changes: 4 additions & 2 deletions pymongo/synchronous/mongo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2741,8 +2741,10 @@ def __exit__(
try:
self.handle(exc_type, exc_val)
finally:
if self._pool_checkout is not None:
self._pool_checkout.__exit__(exc_type, exc_val, exc_tb)
pool_checkout = self._pool_checkout
self._pool_checkout = None # to break the reference cycle before cleanup can raise
if pool_checkout is not None:
pool_checkout.__exit__(exc_type, exc_val, exc_tb)

@classmethod
def for_existing_conn(
Expand Down
Loading