original_docstring: 
          Claim ownership of the PID file.
  
          :raises ~portalocker.LockException:
              If locking failed.
              For example, if already :meth:`locked`.
          
docstring: Claim ownership of the PID file.
docstring_tokens: Claim ownership of the PID file .
code: def acquire(self) -> None:
          """
          Claim ownership of the PID file.
  
          :raises ~portalocker.LockException:
              If locking failed.
              For example, if already :meth:`locked`.
          """
          # Need the parent directory to exist before making the file.
          self._lock_path.parent.mkdir(parents=True, exist_ok=True)
          # Open with "append" which creates the file if missing.
          file_handle = open(  # pylint: disable=consider-using-with
              self._lock_path, 'a'
          )
          try:
              portalocker.lock(
                  file_handle, portalocker.LOCK_EX | portalocker.LOCK_NB
              )
          except portalocker.LockException:
              file_handle.close()
              raise
          # Acquiring the lock should not be possible
          # if the script already has a lock on it.
          # But checking anyway for logic issues.
          assert self._file_handle is None
          # Store the handle to close later.
          self._file_handle = file_handle
          # Write in the PID.
          file_handle.seek(0)
          file_handle.truncate()
          file_handle.writelines([str(os.getpid())])
          file_handle.flush()
code_tokens: def acquire ( self ) -> None : self . _lock_path . parent . mkdir ( parents = True , exist_ok = True ) file_handle = open ( self . _lock_path , 'a' ) try : portalocker . lock ( file_handle , portalocker . LOCK_EX | portalocker . LOCK_NB ) except portalocker . LockException : file_handle . close ( ) raise assert self . _file_handle is None self . _file_handle = file_handle file_handle . seek ( 0 ) file_handle . truncate ( ) file_handle . writelines ( [ str ( os . getpid ( ) ) ] ) file_handle . flush ( )
short_docstring: Claim ownership of the PID file.
short_docstring_tokens: Claim ownership of the PID file .
comment: """
          Claim ownership of the PID file.
  
          :raises ~portalocker.LockException:
              If locking failed.
              For example, if already :meth:`locked`.
          """$SEP$# Need the parent directory to exist before making the file.$SEP$# Open with "append" which creates the file if missing.$SEP$# pylint: disable=consider-using-with$SEP$# Acquiring the lock should not be possible$SEP$# if the script already has a lock on it.$SEP$# But checking anyway for logic issues.$SEP$# Store the handle to close later.$SEP$# Write in the PID.