code: def try_for(fn, timeout=5.0, delay=0.1):
      """Calls ``fn`` every ``delay`` seconds until it returns True or
      ``timeout`` seconds elapse. Returns True if the lock was acquired, or False
      if the timeout was reached.
  
      :param timeout: Length of time (in seconds) to keep retrying to acquire the
          lock. 0 means return immediately. Only used when blocking is False.
      :param delay: How often (in seconds) to retry acquiring the lock during
          the timeout period. Only used when blocking is False and timeout > 0.
      """
  
      until = time.time() + timeout
      v = fn()
      while not v and time.time() < until:
          time.sleep(delay)
          v = fn()
      return v
  
file_path: whoosh/src/whoosh/util/filelock.py
imports: import errno
  import os
  import sys
  import time
label_desc: Use image node_id 1 for calling a global function with example usage: try_for(fn, timeout, delay) and returns: v