From 9d8024d9ea867799e3df838bb4761925b0286cf6 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 15 Jun 2018 11:58:01 -0700 Subject: [PATCH] PYTHON-1590 Avoid thread limit in tests --- test/test_retryable_writes.py | 2 ++ test/test_transactions.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/test_retryable_writes.py b/test/test_retryable_writes.py index c09cef7cc..42f09ed11 100644 --- a/test/test_retryable_writes.py +++ b/test/test_retryable_writes.py @@ -97,6 +97,8 @@ def create_test(scenario_def, test): error = None db = rs_or_single_client(**test['clientOptions']).pymongo_test + # Close the client explicitly to avoid having too many threads open. + self.addCleanup(db.client.close) try: result = run_operation(db.test, test) except (ConnectionFailure, OperationFailure) as exc: diff --git a/test/test_transactions.py b/test/test_transactions.py index 9e0df00ad..b77253eca 100644 --- a/test/test_transactions.py +++ b/test/test_transactions.py @@ -347,6 +347,8 @@ def create_test(scenario_def, test): # with ScenarioDict. client = rs_client(event_listeners=[listener], **dict(test['clientOptions'])) + # Close the client explicitly to avoid having too many threads open. + self.addCleanup(client.close) # Kill all sessions before and after each test to prevent an open # transaction (from a test failure) from blocking collection/database