def wait_for_master(topology):
 def get_master():
  try:
   return topology.select_server(writable_server_selector, 0)
  except ConnectionFailure:
   return None
 return wait_until(get_master, 'find master')

def wait_for_master ( topology ) : def get_master ( ) : try : return topology . select_server ( writable_server_selector , 0 ) except ConnectionFailure : return None return wait_until ( get_master , 'find master' )
wait for a topology to discover a writable server .