File tree Expand file tree Collapse file tree 6 files changed +16
-16
lines changed Expand file tree Collapse file tree 6 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -1559,13 +1559,13 @@ async def close(self) -> None:
1559
1559
# Stop the periodic task thread and then send pending killCursor
1560
1560
# requests before closing the topology.
1561
1561
self ._kill_cursors_executor .close ()
1562
+ if not _IS_SYNC :
1563
+ await self ._kill_cursors_executor .join ()
1562
1564
await self ._process_kill_cursors ()
1563
1565
await self ._topology .close ()
1564
1566
if self ._encrypter :
1565
1567
# TODO: PYTHON-1921 Encrypted MongoClients cannot be re-opened.
1566
1568
await self ._encrypter .close ()
1567
- if not _IS_SYNC :
1568
- await self ._kill_cursors_executor .join ()
1569
1569
self ._closed = True
1570
1570
1571
1571
if not _IS_SYNC :
Original file line number Diff line number Diff line change @@ -111,8 +111,6 @@ async def close(self) -> None:
111
111
open() restarts the monitor after closing.
112
112
"""
113
113
self .gc_safe_close ()
114
- if not _IS_SYNC :
115
- await self ._executor .join ()
116
114
117
115
async def join (self , timeout : Optional [int ] = None ) -> None :
118
116
"""Wait for the monitor to stop."""
@@ -191,10 +189,12 @@ def gc_safe_close(self) -> None:
191
189
self ._rtt_monitor .gc_safe_close ()
192
190
self .cancel_check ()
193
191
192
+ async def join (self , timeout : Optional [int ] = None ) -> None :
193
+ await self ._executor .join (timeout )
194
+ await self ._rtt_monitor .join ()
195
+
194
196
async def close (self ) -> None :
195
197
self .gc_safe_close ()
196
- if not _IS_SYNC :
197
- await self ._executor .join ()
198
198
await self ._rtt_monitor .close ()
199
199
# Increment the generation and maybe close the socket. If the executor
200
200
# thread has the socket checked out, it will be closed when checked in.
@@ -464,8 +464,6 @@ async def close(self) -> None:
464
464
self .gc_safe_close ()
465
465
# Increment the generation and maybe close the socket. If the executor
466
466
# thread has the socket checked out, it will be closed when checked in.
467
- if not _IS_SYNC :
468
- await self ._executor .join ()
469
467
await self ._pool .reset ()
470
468
471
469
async def add_sample (self , sample : float ) -> None :
Original file line number Diff line number Diff line change @@ -520,6 +520,8 @@ async def _process_change(
520
520
and self ._description .topology_type not in SRV_POLLING_TOPOLOGIES
521
521
):
522
522
await self ._srv_monitor .close ()
523
+ if not _IS_SYNC :
524
+ await self ._srv_monitor .join ()
523
525
524
526
# Clear the pool from a failed heartbeat.
525
527
if reset_pool :
Original file line number Diff line number Diff line change @@ -1553,13 +1553,13 @@ def close(self) -> None:
1553
1553
# Stop the periodic task thread and then send pending killCursor
1554
1554
# requests before closing the topology.
1555
1555
self ._kill_cursors_executor .close ()
1556
+ if not _IS_SYNC :
1557
+ self ._kill_cursors_executor .join ()
1556
1558
self ._process_kill_cursors ()
1557
1559
self ._topology .close ()
1558
1560
if self ._encrypter :
1559
1561
# TODO: PYTHON-1921 Encrypted MongoClients cannot be re-opened.
1560
1562
self ._encrypter .close ()
1561
- if not _IS_SYNC :
1562
- self ._kill_cursors_executor .join ()
1563
1563
self ._closed = True
1564
1564
1565
1565
if not _IS_SYNC :
Original file line number Diff line number Diff line change @@ -111,8 +111,6 @@ def close(self) -> None:
111
111
open() restarts the monitor after closing.
112
112
"""
113
113
self .gc_safe_close ()
114
- if not _IS_SYNC :
115
- self ._executor .join ()
116
114
117
115
def join (self , timeout : Optional [int ] = None ) -> None :
118
116
"""Wait for the monitor to stop."""
@@ -191,10 +189,12 @@ def gc_safe_close(self) -> None:
191
189
self ._rtt_monitor .gc_safe_close ()
192
190
self .cancel_check ()
193
191
192
+ def join (self , timeout : Optional [int ] = None ) -> None :
193
+ self ._executor .join (timeout )
194
+ self ._rtt_monitor .join ()
195
+
194
196
def close (self ) -> None :
195
197
self .gc_safe_close ()
196
- if not _IS_SYNC :
197
- self ._executor .join ()
198
198
self ._rtt_monitor .close ()
199
199
# Increment the generation and maybe close the socket. If the executor
200
200
# thread has the socket checked out, it will be closed when checked in.
@@ -464,8 +464,6 @@ def close(self) -> None:
464
464
self .gc_safe_close ()
465
465
# Increment the generation and maybe close the socket. If the executor
466
466
# thread has the socket checked out, it will be closed when checked in.
467
- if not _IS_SYNC :
468
- self ._executor .join ()
469
467
self ._pool .reset ()
470
468
471
469
def add_sample (self , sample : float ) -> None :
Original file line number Diff line number Diff line change @@ -520,6 +520,8 @@ def _process_change(
520
520
and self ._description .topology_type not in SRV_POLLING_TOPOLOGIES
521
521
):
522
522
self ._srv_monitor .close ()
523
+ if not _IS_SYNC :
524
+ self ._srv_monitor .join ()
523
525
524
526
# Clear the pool from a failed heartbeat.
525
527
if reset_pool :
You can’t perform that action at this time.
0 commit comments