Skip to content

Commit 1c67651

Browse files
committed
ahh i need to trigger garbage collect
1 parent ede8307 commit 1c67651

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

test/asynchronous/test_monitor.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,19 @@ async def test_cleanup_executors_on_client_del(self):
7676
)
7777

7878
def resource_warning_caught():
79-
count = 0
79+
gc.collect()
80+
print(w)
8081
for warning in w:
82+
print(warning)
8183
if (
8284
issubclass(warning.category, ResourceWarning)
8385
and "Call AsyncMongoClient.close() to safely shut down your client and free up resources."
8486
in str(warning.message)
8587
):
86-
count += 1
87-
return count >= 2
88+
return True
89+
return False
8890

89-
try:
90-
await async_wait_until(
91-
resource_warning_caught, "catch resource warning", timeout=30
92-
)
93-
except AssertionError as exc:
94-
if "catch resource warning" not in str(exc):
95-
raise
91+
await async_wait_until(resource_warning_caught, "catch resource warning")
9692

9793
async def test_cleanup_executors_on_client_close(self):
9894
client = await self.create_client()

test/test_monitor.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,19 @@ def test_cleanup_executors_on_client_del(self):
7474
wait_until(partial(unregistered, ref), f"unregister executor: {name}", timeout=5)
7575

7676
def resource_warning_caught():
77-
count = 0
77+
gc.collect()
78+
print(w)
7879
for warning in w:
80+
print(warning)
7981
if (
8082
issubclass(warning.category, ResourceWarning)
8183
and "Call MongoClient.close() to safely shut down your client and free up resources."
8284
in str(warning.message)
8385
):
84-
count += 1
85-
return count >= 2
86-
87-
try:
88-
wait_until(resource_warning_caught, "catch resource warning", timeout=30)
89-
except AssertionError as exc:
90-
if "catch resource warning" not in str(exc):
91-
raise
86+
return True
87+
return False
88+
89+
wait_until(resource_warning_caught, "catch resource warning")
9290

9391
def test_cleanup_executors_on_client_close(self):
9492
client = self.create_client()

0 commit comments

Comments
 (0)