@@ -730,18 +730,23 @@ def _check_with_socket(self, *args, **kwargs):
730730 if ismaster_count [0 ] in (1 , 3 ):
731731 return IsMaster ({'ok' : 1 , 'maxWireVersion' : 6 }), 0
732732 else :
733- raise AutoReconnect ('mock monitor error' )
733+ raise AutoReconnect (
734+ 'mock monitor error #%s' % (ismaster_count [0 ],))
734735
735736 t = create_mock_topology (monitor_class = TestMonitor )
736737 server = wait_for_master (t )
737738 self .assertEqual (1 , ismaster_count [0 ])
738739 self .assertEqual (SERVER_TYPE .Standalone ,
739740 server .description .server_type )
740741
741- # Second ismaster call, then immediately the third .
742+ # Second ismaster call.
742743 t .request_check_all ()
743- self .assertEqual (3 , ismaster_count [0 ])
744+ # The third ismaster call (the immediate retry) happens sometime soon
745+ # after the failed check triggered by request_check_all. Wait until
746+ # the server becomes known again.
747+ t .select_server (writable_server_selector , 0.250 )
744748 self .assertEqual (SERVER_TYPE .Standalone , get_type (t , 'a' ))
749+ self .assertEqual (3 , ismaster_count [0 ])
745750
746751 def test_internal_monitor_error (self ):
747752 exception = AssertionError ('internal error' )
0 commit comments