code: def wait_for(text, finish=None, io=None):
      
      if finish:
          finish.set()
          time.sleep(0.1) # threads, sigh
      if not io:
          io = sys.stdout
      finish = threading.Event()
      io.write(text)
      def _wait():
          while not finish.is_set():
              io.write('.')
              io.flush()
              finish.wait(timeout=1)
          io.write('\n')
      threading.Thread(target=_wait).start()
      return finish
docs: Displays dots until returned event is set