File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -1307,13 +1307,7 @@ def __init__(
1307
1307
# release the lock.
1308
1308
self ._fork_lock = threading .Lock ()
1309
1309
self .reset ()
1310
-
1311
- # Run scheduled healthcheck to avoid stale invalidations in idle connections.
1312
- if self .cache is not None and self ._scheduler is not None :
1313
- self ._hc_cancel_event = threading .Event ()
1314
- self ._hc_thread = self ._scheduler .run_with_interval (
1315
- self ._perform_health_check , 2 , self ._hc_cancel_event
1316
- )
1310
+ self .run_scheduled_healthcheck ()
1317
1311
1318
1312
def __repr__ (self ) -> (str , str ):
1319
1313
return (
@@ -1513,6 +1507,14 @@ def set_retry(self, retry: "Retry") -> None:
1513
1507
for conn in self ._in_use_connections :
1514
1508
conn .retry = retry
1515
1509
1510
+ def run_scheduled_healthcheck (self ) -> None :
1511
+ # Run scheduled healthcheck to avoid stale invalidations in idle connections.
1512
+ if self .cache is not None and self ._scheduler is not None :
1513
+ self ._hc_cancel_event = threading .Event ()
1514
+ self ._hc_thread = self ._scheduler .run_with_interval (
1515
+ self ._perform_health_check , 2 , self ._hc_cancel_event
1516
+ )
1517
+
1516
1518
def _perform_health_check (self , done : threading .Event ) -> None :
1517
1519
self ._checkpid ()
1518
1520
with self ._lock :
Original file line number Diff line number Diff line change @@ -115,6 +115,7 @@ def get_master_address(self):
115
115
connection_pool = self .connection_pool_ref ()
116
116
if connection_pool is not None :
117
117
connection_pool .disconnect (inuse_connections = False )
118
+ connection_pool .run_scheduled_healthcheck ()
118
119
return master_address
119
120
120
121
def rotate_slaves (self ):
Original file line number Diff line number Diff line change 1
- import threading
2
1
import time
3
2
4
3
import pytest
@@ -38,7 +37,7 @@ def r(request):
38
37
39
38
@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
40
39
@pytest .mark .onlynoncluster
41
- # @skip_if_resp_version(2)
40
+ @skip_if_resp_version (2 )
42
41
class TestCache :
43
42
@pytest .mark .parametrize (
44
43
"r" ,
You can’t perform that action at this time.
0 commit comments