@@ -780,24 +780,26 @@ def update_routing_table(self, *, database, bookmarks):
780
780
:raise neo4j.exceptions.ServiceUnavailable:
781
781
"""
782
782
# copied because it can be modified
783
- existing_routers = list (self .routing_tables [database ].routers )
783
+ existing_routers = set (self .routing_tables [database ].routers )
784
784
785
- has_tried_initial_routers = False
786
- if self .routing_tables [database ].missing_fresh_writer ():
785
+ prefer_initial_routing_address = \
786
+ self .routing_tables [database ].missing_fresh_writer ()
787
+
788
+ if prefer_initial_routing_address :
787
789
# TODO: Test this state
788
- has_tried_initial_routers = True
789
790
if self .update_routing_table_from (
790
791
self .first_initial_routing_address , database = database ,
791
792
bookmarks = bookmarks
792
793
):
793
794
# Why is only the first initial routing address used?
794
795
return
795
- if self .update_routing_table_from (* existing_routers , database = database ,
796
- bookmarks = bookmarks ):
796
+ if self .update_routing_table_from (
797
+ * (existing_routers - {self .first_initial_routing_address }),
798
+ database = database , bookmarks = bookmarks
799
+ ):
797
800
return
798
801
799
- if (not has_tried_initial_routers
800
- and self .first_initial_routing_address not in existing_routers ):
802
+ if not prefer_initial_routing_address :
801
803
if self .update_routing_table_from (
802
804
self .first_initial_routing_address , database = database ,
803
805
bookmarks = bookmarks
0 commit comments