docs: def retry(func, exception_type, quit_event):
      """
      Run the function, retrying when the specified exception_type occurs.
  
      Poll quit_event on each iteration, to be responsive to an external
      exit request.
      """
      while True:
          if quit_event.is_set():
              raise StopIteration
          try:
              return func()
          except exception_type:
              pass