code: def wait(timeout=None, flush=True):
      
      if timeout is not None:
          timeout = timeout + _time.clock() # timeout at this time
      while True:
          if _eventQueue:
              return _eventQueue.pop(0)
          if flush:
              # a full 'round' of events need to be processed before flushing
              _tdl.flush()
          if timeout and _time.clock() >= timeout:
              return None # return None on timeout
          _time.sleep(0.001) # sleep 1ms
          _processEvents()
docs: Wait for an event.
  
      Args:
          timeout (Optional[int]): The time in seconds that this function will
              wait before giving up and returning None.
  
              With the default value of None, this will block forever.
          flush (bool): If True a call to :any:`tdl.flush` will be made before
              listening for events.
  
      Returns: Type[Event]: An event, or None if the function
               has timed out.
               Anything added via :any:`push` will also be returned.