docs: def wait (cond, msg=None, _timeout=10, _raiseException=True):
      """Waits either a specified number of seconds, e.g.:
  
      .. code-block:: python
  
          wait(1.2)
  
      or for a given condition to be True.  Conditions may be take
      several forms: Python string expression, lambda, or function,
      e.g.:
  
      .. code-block:: python
  
          wait('instrument_mode == "SAFE"')
          wait(lambda: instrument_mode == "SAFE")
  
          def isSafe(): return instrument_mode == "SAFE"
          wait(isSafe)
  
      The default ``_timeout`` is 10 seconds.  If the condition is not
      satisfied before the timeout has elapsed, an
      :exception:``APITimeoutError`` exception is raised.
  
      The :exception:``APITimeoutError`` exception may be supressed in
      favor of returning ``True`` on success (i.e. condition satisfied)
      and ``False`` on failure (i.e. timeout exceeded) by setting the
      ``_raiseException`` parameter to ``False``.
       
      The :exception:``FalseWaitError`` will be thrown only if a boolean 
      with value "False" is passed as an argument to wait. The purpose of 
      this is to avoid infinite loops and catch conditional arguments are
      not passed in as strings and therefore evaluated before the wait
      function gets called. 
      
      These parameters are prefixed with an underscore so they may also
      be used to control exception handling when sending commands.
      Since methods that generate commands take keyword arguments, we
      did not want these parameter names to conflict with command
      parameter names.
      """
      status  = False
      delay   = 0.25
      elapsed = 0
  
      if msg is None and type(cond) is str:
          msg = cond
  
      if type(cond) is bool:
          if cond:
              log.warn('Boolean passed as argument to wait. Make sure argument to wait is surrounded by a lambda or " "')
          else:
              raise FalseWaitError(msg)
  
      if type(cond) in (int, float):
          gevent.sleep(cond)
          status = True
      else:
          while True:
              if _timeout is not None and elapsed >= _timeout:
                  if _raiseException:
                      raise APITimeoutError(_timeout, msg)
                  else:
                      status = False
                      break
  
              if type(cond) is str:
                  caller = inspect.stack()[1][0]
                  status = eval(cond, caller.f_globals, caller.f_locals)
              elif callable(cond):
                  status = cond()
              else:
                  status = cond
  
              if status:
                  break
  
              gevent.sleep(delay)
              elapsed += delay
  
      return status