def DistributedWaitForReadyMidasTalker (midastalker_list, immediate_return,
                                        timeout=None) :
  """ Given a list of MidasTalkers, this returns a list of all 'ready'
  MidasTalkers.  Take the given timeout, distribute it evenly over all
  MidasTalkers so that the maximum wait (if all are unavailable) is
  the given timeout.  If none are ready, a full timeout seconds
  elapse, and an empty list is returned.  With an immediate return,
  this function returns as soon as ANY socket is ready, without it,
  each talkers may wait the full distributed quanta of time.  """

  # Choose between distributing the timeout, and having no timeout.
  if timeout==None :
    distributed_timeout = None
  else :
    distributed_timeout = timeout / len(midastalker_list)
    
  # Gather all MidasTalkers that are available in a list
  result = []
  for mt in midastalker_list :
    if mt.dataReady(distributed_timeout) :
      result.append(mt)
      if immediate_return :   # Get out right away if there's one available
        break
      
  return result