original_docstring: On Windows os.replace, os.chmod and open can yield
          permission errors if executed by two different processes.
docstring: On Windows os.replace, os.chmod and open can yield
  permission errors if executed by two different processes.
docstring_tokens: On Windows os . replace os . chmod and open can yield permission errors if executed by two different processes .
code: def _run_safely(self, fn: _t.Callable, *args: _t.Any, **kwargs: _t.Any) -> _t.Any:
          """On Windows os.replace, os.chmod and open can yield
          permission errors if executed by two different processes."""
          if platform.system() == "Windows":
              output = None
              wait_step = 0.001
              max_sleep_time = 10.0
              total_sleep_time = 0.0
  
              while total_sleep_time < max_sleep_time:
                  try:
                      output = fn(*args, **kwargs)
                  except PermissionError:
                      sleep(wait_step)
                      total_sleep_time += wait_step
                      wait_step *= 2
                  else:
                      break
          else:
              output = fn(*args, **kwargs)
  
          return output
code_tokens: def _run_safely ( self , fn : _t . Callable , * args : _t . Any , ** kwargs : _t . Any ) -> _t . Any : if platform . system ( ) == "Windows" : output = None wait_step = 0.001 max_sleep_time = 10.0 total_sleep_time = 0.0 while total_sleep_time < max_sleep_time : try : output = fn ( * args , ** kwargs ) except PermissionError : sleep ( wait_step ) total_sleep_time += wait_step wait_step *= 2 else : break else : output = fn ( * args , ** kwargs ) return output
short_docstring: On Windows os.replace, os.chmod and open can yield
  permission errors if executed by two different processes.
short_docstring_tokens: On Windows os . replace os . chmod and open can yield permission errors if executed by two different processes .
comment: """On Windows os.replace, os.chmod and open can yield
          permission errors if executed by two different processes."""