@@ -1334,19 +1334,21 @@ def deactivate(self, address):
13341334 log .debug ("[#0000] C: <ROUTING> Deactivating address %r" , address )
13351335 # We use `discard` instead of `remove` here since the former
13361336 # 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 )
13411342 log .debug ("[#0000] C: <ROUTING> table=%r" , self .routing_tables )
13421343 super (Neo4jPool , self ).deactivate (address )
13431344
13441345 def on_write_failure (self , address ):
13451346 """ Remove a writer address from the routing table, if present.
13461347 """
13471348 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 )
13501352 log .debug ("[#0000] C: <ROUTING> table=%r" , self .routing_tables )
13511353
13521354
0 commit comments