original_docstring: registers a cleanup function for removing a lock, by default on atexit
docstring: registers a cleanup function for removing a lock, by default on atexit
docstring_tokens: registers a cleanup function for removing a lock by default on atexit
code: def register_cleanup_lock_removal(lock_path, register=atexit.register):
      """registers a cleanup function for removing a lock, by default on atexit"""
      pid = os.getpid()
  
      def cleanup_on_exit(lock_path=lock_path, original_pid=pid):
          current_pid = os.getpid()
          if current_pid != original_pid:
              # fork
              return
          try:
              lock_path.unlink()
          except (OSError, IOError):
              pass
  
      return register(cleanup_on_exit)
code_tokens: def register_cleanup_lock_removal ( lock_path , register = atexit . register ) : pid = os . getpid ( ) def cleanup_on_exit ( lock_path = lock_path , original_pid = pid ) : current_pid = os . getpid ( ) if current_pid != original_pid : return try : lock_path . unlink ( ) except ( OSError , IOError ) : pass return register ( cleanup_on_exit )
short_docstring: registers a cleanup function for removing a lock, by default on atexit
short_docstring_tokens: registers a cleanup function for removing a lock by default on atexit
comment: """registers a cleanup function for removing a lock, by default on atexit"""$SEP$# fork