1515"""Test the monitor module."""
1616from __future__ import annotations
1717
18+ import asyncio
1819import gc
1920import subprocess
2021import sys
2324
2425sys .path [0 :0 ] = ["" ]
2526
26- from test .asynchronous import AsyncIntegrationTest , connected , unittest
27+ from test .asynchronous import AsyncIntegrationTest , async_client_context , connected , unittest
2728from test .utils import (
2829 ServerAndTopologyEventListener ,
2930 async_wait_until ,
3334
3435_IS_SYNC = False
3536
37+
3638def unregistered (ref ):
3739 gc .collect ()
3840 return ref not in _EXECUTORS
@@ -69,7 +71,9 @@ async def test_cleanup_executors_on_client_del(self):
6971 del client
7072
7173 for ref , name in executor_refs :
72- await async_wait_until (partial (unregistered , ref ), f"unregister executor: { name } " , timeout = 5 )
74+ await async_wait_until (
75+ partial (unregistered , ref ), f"unregister executor: { name } " , timeout = 5
76+ )
7377
7478 async def test_cleanup_executors_on_client_close (self ):
7579 client = await self .create_client ()
@@ -79,12 +83,19 @@ async def test_cleanup_executors_on_client_close(self):
7983 await client .close ()
8084
8185 for executor in executors :
82- await async_wait_until (lambda : executor ._stopped , f"closed executor: { executor ._name } " , timeout = 5 )
86+ await async_wait_until (
87+ lambda : executor ._stopped , f"closed executor: { executor ._name } " , timeout = 5
88+ )
8389
84- async def test_no_thread_start_runtime_err_on_shutdown (self ):
90+ @async_client_context .require_sync
91+ def test_no_thread_start_runtime_err_on_shutdown (self ):
8592 """Test we silence noisy runtime errors fired when the AsyncMongoClient spawns a new thread
8693 on process shutdown."""
87- command = [sys .executable , "-c" , "from pymongo import AsyncMongoClient; c = AsyncMongoClient()" ]
94+ command = [
95+ sys .executable ,
96+ "-c" ,
97+ "from pymongo import AsyncMongoClient; c = AsyncMongoClient()" ,
98+ ]
8899 completed_process : subprocess .CompletedProcess = subprocess .run (
89100 command , capture_output = True
90101 )
0 commit comments