@@ -451,7 +451,7 @@ async def deactivate(self, address):
451451
452452 await self ._close_connections (closable_connections )
453453
454- def on_write_failure (self , address ):
454+ async def on_write_failure (self , address ):
455455 raise WriteServiceUnavailable (
456456 "No write service available for pool {}" .format (self )
457457 )
@@ -949,17 +949,19 @@ async def deactivate(self, address):
949949 log .debug ("[#0000] _: <POOL> deactivating address %r" , address )
950950 # We use `discard` instead of `remove` here since the former
951951 # will not fail if the address has already been removed.
952- for database in self .routing_tables .keys ():
953- self .routing_tables [database ].routers .discard (address )
954- self .routing_tables [database ].readers .discard (address )
955- self .routing_tables [database ].writers .discard (address )
952+ async with self .refresh_lock :
953+ for database in self .routing_tables .keys ():
954+ self .routing_tables [database ].routers .discard (address )
955+ self .routing_tables [database ].readers .discard (address )
956+ self .routing_tables [database ].writers .discard (address )
956957 log .debug ("[#0000] _: <POOL> table=%r" , self .routing_tables )
957958 await super (AsyncNeo4jPool , self ).deactivate (address )
958959
959- def on_write_failure (self , address ):
960+ async def on_write_failure (self , address ):
960961 """ Remove a writer address from the routing table, if present.
961962 """
962963 log .debug ("[#0000] _: <POOL> removing writer %r" , address )
963- for database in self .routing_tables .keys ():
964- self .routing_tables [database ].writers .discard (address )
964+ async with self .refresh_lock :
965+ for database in self .routing_tables .keys ():
966+ self .routing_tables [database ].writers .discard (address )
965967 log .debug ("[#0000] _: <POOL> table=%r" , self .routing_tables )
0 commit comments