File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -1402,6 +1402,7 @@ def __init__(
1402
1402
self .health_check_response = ["pong" , self .HEALTH_CHECK_MESSAGE ]
1403
1403
else :
1404
1404
self .health_check_response = [b"pong" , self .health_check_response_b ]
1405
+ self ._connection_lock = threading .Lock ()
1405
1406
self .reset ()
1406
1407
1407
1408
def __enter__ (self ):
@@ -1466,12 +1467,14 @@ def execute_command(self, *args):
1466
1467
# subscribed to one or more channels
1467
1468
1468
1469
if self .connection is None :
1469
- self .connection = self .connection_pool .get_connection (
1470
- "pubsub" , self .shard_hint
1471
- )
1472
- # register a callback that re-subscribes to any channels we
1473
- # were listening to when we were disconnected
1474
- self .connection .register_connect_callback (self .on_connect )
1470
+ with self ._connection_lock :
1471
+ if self .connection is None :
1472
+ self .connection = self .connection_pool .get_connection (
1473
+ "pubsub" , self .shard_hint
1474
+ )
1475
+ # register a callback that re-subscribes to any channels we
1476
+ # were listening to when we were disconnected
1477
+ self .connection .register_connect_callback (self .on_connect )
1475
1478
connection = self .connection
1476
1479
kwargs = {"check_health" : not self .subscribed }
1477
1480
if not self .subscribed :
You can’t perform that action at this time.
0 commit comments