code: def search_for_count(self, ** args):
          
          if "timeout" not in args.keys():
              timeout = self.TIMEOUT
          elif args["timeout"]:
              timeout = args["timeout"]
          args["timeout"] = timeout / 15
  
          if "count" not in args.keys():
              raise EmailException("Count param not defined!")
          else:
              count = int(args["count"])
              del args["count"]
  
          results = None
          timer = timeout
          count = 0
          while count < timer:
              try:
                  results = self.search(** args)
              except EmailException:
                  if count == 0:
                      return []
  
              if results and len(results) == count:
                  return results
              else:
                  time.sleep(15)
                  count += 15
          if count >= timer:
              raise EmailException("Failed to match criteria %s in %s minutes" %
                                   (args, timeout / 60))
docs: A search that keeps searching up until timeout for a
          specific number of matches to a search. If timeout is not
          specified we use the default.  If count= is not specified we
          will fail. Return values are the same as search(), except for count=0,
          where we will return an empty list. Use this if you need to wait for a
          number of emails other than 1.
  
          @Params
          args - dict of arguments to use in search:
                 count - number of emails to search for
                 timeout - seconds to try search before timing out
          @Returns
          List of message numbers matched by search