+
    Dfj!                    \  a  0 t $ R t^ RIHt ^ RIt^ RIHtHtHt	 ^ RI
Ht ^ RIHtHtHt ^ RIHtHt ^ RIHt ^ RIHt  ! R	 R
]4      t]! ]4       ! R R4      4       t]! ]4       ! R R4      4       t]! 4       tR
]R&    ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t R# )z
PID file.
)annotationsN)getpidkillname)TracebackType)AnyOptionalType)	Interfaceimplementer)Logger)FilePathc                  b    ] tR t^tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
RtR# )IPIDFilez-
Manages a file that remembers a process ID.
c                   V ^8  d   QhRR/#    returnint )formats   "E/usr/lib/python3/dist-packages/twisted/application/runner/_pidfile.py__annotate__IPIDFile.__annotate__   s     	 	# 	    c                     R# )z
Read the process ID stored in this PID file.

@return: The contained process ID.

@raise NoPIDFound: If this PID file does not exist.
@raise EnvironmentError: If this PID file cannot be read.
@raise ValueError: If this PID file's content is invalid.
Nr   r   r   r   readIPIDFile.read       r   c                   V ^8  d   QhRR/# r   r   Noner   )r   s   "r   r   r   %   s      T r   c                     R# )zv
Store the PID of the current process in this PID file.

@raise EnvironmentError: If this PID file cannot be written.
Nr   r   r   r   writeRunningPIDIPIDFile.writeRunningPID%   r   r   c                   V ^8  d   QhRR/# r    r   )r   s   "r   r   r   ,   s      D r   c                     R# )zU
Remove this PID file.

@raise EnvironmentError: If this PID file cannot be removed.
Nr   r   r   r   removeIPIDFile.remove,   r   r   c                   V ^8  d   QhRR/# r   r   boolr   )r   s   "r   r   r   3   s      t r   c                     R# )a  
Determine whether there is a running process corresponding to the PID
in this PID file.

@return: True if this PID file contains a PID and a process with that
    PID is currently running; false otherwise.

@raise EnvironmentError: If this PID file cannot be read.
@raise InvalidPIDFileError: If this PID file's content is invalid.
@raise StalePIDFileError: If this PID file's content refers to a PID
    for which there is no corresponding running process.
Nr   r   r   r   	isRunningIPIDFile.isRunning3   r   r   c                   V ^8  d   QhRR/# )r   r   z
'IPIDFile'r   )r   s   "r   r   r   A   s      z r   c                     R# )z
Enter a context using this PIDFile.

Writes the PID file with the PID of the running process.

@raise AlreadyRunningError: A process corresponding to the PID in this
    PID file is already running.
Nr   r   r   r   	__enter__IPIDFile.__enter__A   r   r   c               (    V ^8  d   QhRRRRRRRR/# )	r   excTypeOptional[Type[BaseException]]excValueOptional[BaseException]	tracebackOptional[TracebackType]r   zOptional[bool]r   )r   s   "r   r   r   K   s0     	 	.	)	 +	 
		r   c                    R# )z;
Exit a context using this PIDFile.

Removes the PID file.
Nr   )r4   r6   r8   s   &&&r   __exit__IPIDFile.__exit__K   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r#   r'   r-   r1   r;   __static_attributes__r   r   r   r   r      s*    		 	r   r   c                      ] tR t^WtRt]! 4       t]R R l4       tR R lt	R R lt
R R	 ltR
 R ltR R ltR R lt]R R l4       tR R ltR R ltRtR# )PIDFilez
Concrete implementation of L{IPIDFile}.

This implementation is presently not supported on non-POSIX platforms.
Specifically, calling L{PIDFile.isRunning} will raise
L{NotImplementedError}.
c                    V ^8  d   QhRRRR/# )r   pidr   r   bytesr   )r   s   "r   r   PIDFile.__annotate__d   s     ( (S (U (r   c                :    \        V 4       R2P                  4       # )z`
Format a PID file's content.

@param pid: A process ID.

@return: Formatted PID file contents.

)r   encoderF   s   &r   _formatPIDFile._formatc   s     c(2%%''r   c                    V ^8  d   QhRRRR/# )r   filePathzFilePath[Any]r   r!   r   )r   s   "r   r   rH   n   s     ! ! !4 !r   c                    Wn         R# )z4
@param filePath: The path to the PID file on disk.
NrP   )selfrP   s   &&r   __init__PIDFile.__init__n   s	     !r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rH   t   s      c r   c                	f   R p V P                   P                  4       ;_uu_ 4       pV F  p M	  RRR4        \        T4      #   + '       g   i     L; i  \         d1   pTP                  \        P                  8X  d   \        R4      hh Rp?ii ; i  \         d    \        RT: 24      hi ; i)r   NPID file does not existz#non-integer PID value in PID file: )	rP   openOSErrorerrnoENOENT
NoPIDFoundr   
ValueErrorInvalidPIDFileError)rS   	pidStringfhes   &   r   r   PIDFile.readt   s    		##%%!#I "$ &	y>! &%  	ww%,,& !:;;	  	%5i]C 	s>   "A 
AA 
B A	A A B"+BBB0c                    V ^8  d   QhRRRR/# r   rF   r   r   r!   r   )r   s   "r   r   rH      s     8 8# 8$ 8r   c                \    V P                   P                  V P                  VR7      4       R# )zz
Store a PID in this PID file.

@param pid: A PID to store.

@raise EnvironmentError: If this PID file cannot be written.
rL   N)rP   
setContentrM   rS   rF   s   &&r   _writePIDFile._write   s!     	  #!67r   c                   V ^8  d   QhRR/# r    r   )r   s   "r   r   rH      s       r   c                	8    V P                  \        4       4       R # N)ri   r   rS   s   &r   r#   PIDFile.writeRunningPID   s    FHr   c                   V ^8  d   QhRR/# r    r   )r   s   "r   r   rH      s       r   c                	:    V P                   P                  4        R # rm   )rP   r'   rn   s   &r   r'   PIDFile.remove   s    r   c                   V ^8  d   QhRR/# r*   r   )r   s   "r   r   rH      s     	X 	X4 	Xr   c                	     V P                  4       p\        R8X  d   T P                  T4      # \	        R\         24      h  \         d     R # i ; i)Fposixz isRunning is not implemented on )r   r]   SYSTEM_NAME_pidIsRunningPOSIXNotImplementedErrorrh   s   & r   r-   PIDFile.isRunning   sT    	))+C '!**3//%(H&VWW  		s   A   AAc                    V ^8  d   QhRRRR/# )r   rF   r   r   r+   r   )r   s   "r   r   rH      s        r   c                     \        V ^ 4       R#   \         dV   pTP                  \        P                  8X  d   \	        R4      hTP                  \        P
                  8X  d    Rp?R# h Rp?ii ; i)a  
POSIX implementation for running process check.

Determine whether there is a running process corresponding to the given
PID.

@param pid: The PID to check.

@return: True if the given PID is currently running; false otherwise.

@raise EnvironmentError: If this PID file cannot be read.
@raise InvalidPIDFileError: If this PID file's content is invalid.
@raise StalePIDFileError: If this PID file's content refers to a PID
    for which there is no corresponding running process.
Tz'PID file refers to non-existing processN)r   rZ   r[   ESRCHStalePIDFileErrorEPERM)rF   rb   s   & r   rw   PIDFile._pidIsRunningPOSIX   sY    "
	aL   	ww%++%'(QRREKK'	s    A0A	A+*A++A0c                   V ^8  d   QhRR/# )r   r   z	'PIDFile'r   )r   s   "r   r   rH      s      9 r   c                	     V P                  4       '       d   \        4       h V P                  4        V #   \         d    T P                  P	                  R 4        L:i ; i)z&Replacing stale PID file: {log_source})r-   AlreadyRunningErrorr}   _loginfor#   rn   s   &r   r1   PIDFile.__enter__   sZ    	E~~)++   	 ! 	EIINNCD	Es   5 
5 &AAc               (    V ^8  d   QhRRRRRRRR/# 	r   r4   r5   r6   r7   r8   r9   r   r!   r   )r   s   "r   r   rH      s2      . * +	
 
r   c                	&    V P                  4        R # rm   )r'   rS   r4   r6   r8   s   &&&&r   r;   PIDFile.__exit__   s     	r   rR   N)r=   r>   r?   r@   rA   r   r   staticmethodrM   rT   r   ri   r#   r'   r-   rw   r1   r;   rB   r   r   r   rD   rD   W   sd     8D( (!$8	X  8 r   rD   c                  z    ] tR t^tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltRtR# )NonePIDFilez
PID file implementation that does nothing.

This is meant to be used as a "active None" object in place of a PID file
when no PID file is desired.
c                   V ^8  d   QhRR/# r    r   )r   s   "r   r   NonePIDFile.__annotate__   s      $ r   c                	    R # rm   r   rn   s   &r   rT   NonePIDFile.__init__   s    r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     4 4c 4r   c                	    \        R 4      h)rX   )r]   rn   s   &r   r   NonePIDFile.read   s    233r   c                    V ^8  d   QhRRRR/# re   r   )r   s   "r   r   r      s     
> 
># 
>$ 
>r   c                6    \        \        P                  R4      h)z
Store a PID in this PID file.

@param pid: A PID to store.

@raise EnvironmentError: If this PID file cannot be written.

@note: This implementation always raises an L{EnvironmentError}.
zOperation not permitted)rZ   r[   r~   rh   s   &&r   ri   NonePIDFile._write   s     ekk#<==r   c                   V ^8  d   QhRR/# r    r   )r   s   "r   r   r      s       r   c                	(    V P                  ^ 4       R# )    N)ri   rn   s   &r   r#   NonePIDFile.writeRunningPID   s    Ar   c                   V ^8  d   QhRR/# r    r   )r   s   "r   r   r      s     A A Ar   c                	6    \        \        P                  R 4      h)zNo such file or directory)rZ   r[   r\   rn   s   &r   r'   NonePIDFile.remove   s    ell$?@@r   c                   V ^8  d   QhRR/# r*   r   )r   s   "r   r   r      s      4 r   c                	    R # )Fr   rn   s   &r   r-   NonePIDFile.isRunning   s    r   c                   V ^8  d   QhRR/# )r   r   z'NonePIDFile'r   )r   s   "r   r   r      s      = r   c                	    V # rm   r   rn   s   &r   r1   NonePIDFile.__enter__   s    r   c               (    V ^8  d   QhRRRRRRRR/# r   r   )r   s   "r   r   r      s2      . * +	
 
r   c                	    R # rm   r   r   s   &&&&r   r;   NonePIDFile.__exit__   s     r   r   N)r=   r>   r?   r@   rA   rT   r   ri   r#   r'   r-   r1   r;   rB   r   r   r   r   r      s5    4
>A r   r   nonePIDFilec                      ] tR tRtRtRtR# )r   i  z
Process is already running.
r   Nr=   r>   r?   r@   rA   rB   r   r   r   r   r         r   r   c                      ] tR tRtRtRtR# )r_   i
  z 
PID file contents are invalid.
r   Nr   r   r   r   r_   r_   
  r   r   r_   c                      ] tR tRtRtRtR# )r}   i  zO
PID file contents are valid, but there is no process with the referenced
PID.
r   Nr   r   r   r   r}   r}     s    r   r}   c                      ] tR tRtRtRtR# )r]   i  z
No PID found in PID file.
r   Nr   r   r   r   r]   r]     r   r   r]   )!__conditional_annotations__rA   
__future__r   r[   osr   r   r   rv   typesr   typingr   r   r	   zope.interfacer
   r   twisted.loggerr   twisted.python.filepathr   r   rD   r   r   __annotations__	Exceptionr   r_   r}   r]   )r   s   @r   <module>r      s   
 #  0 0  & & 1 ! ,?y ?D Xv v vr X, , ,^ $X %) ) 	  r   