@@ -1334,19 +1334,21 @@ def deactivate(self, address):
1334
1334
log .debug ("[#0000] C: <ROUTING> Deactivating address %r" , address )
1335
1335
# We use `discard` instead of `remove` here since the former
1336
1336
# will not fail if the address has already been removed.
1337
- for database in self .routing_tables .keys ():
1338
- self .routing_tables [database ].routers .discard (address )
1339
- self .routing_tables [database ].readers .discard (address )
1340
- self .routing_tables [database ].writers .discard (address )
1337
+ with self .refresh_lock :
1338
+ for database in self .routing_tables .keys ():
1339
+ self .routing_tables [database ].routers .discard (address )
1340
+ self .routing_tables [database ].readers .discard (address )
1341
+ self .routing_tables [database ].writers .discard (address )
1341
1342
log .debug ("[#0000] C: <ROUTING> table=%r" , self .routing_tables )
1342
1343
super (Neo4jPool , self ).deactivate (address )
1343
1344
1344
1345
def on_write_failure (self , address ):
1345
1346
""" Remove a writer address from the routing table, if present.
1346
1347
"""
1347
1348
log .debug ("[#0000] C: <ROUTING> Removing writer %r" , address )
1348
- for database in self .routing_tables .keys ():
1349
- self .routing_tables [database ].writers .discard (address )
1349
+ with self .refresh_lock :
1350
+ for database in self .routing_tables .keys ():
1351
+ self .routing_tables [database ].writers .discard (address )
1350
1352
log .debug ("[#0000] C: <ROUTING> table=%r" , self .routing_tables )
1351
1353
1352
1354
0 commit comments