%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/application/runner/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/application/runner/__pycache__/_pidfile.cpython-312.pyc

�

Ϫ�f!��T�UdZddlmZddlZddlmZmZmZddl	m
Z
ddlmZm
Z
mZddlmZmZddlmZdd	lmZGd
�de�Zee�Gd�d
��Zee�Gd�d��Ze�Zded<Gd�de�ZGd�de�ZGd�de�ZGd�de�Zy)z
PID file.
�)�annotationsN)�getpid�kill�name)�
TracebackType)�Any�Optional�Type)�	Interface�implementer)�Logger)�FilePathc�P�eZdZdZd	d�Zd
d�Zd
d�Zdd�Zdd�Z								d
d�Z	y)�IPIDFilez5
    Manages a file that remembers a process ID.
    c��y)a+
        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.
        N�r��E/usr/lib/python3/dist-packages/twisted/application/runner/_pidfile.py�readz
IPIDFile.read��rc��y)z�
        Store the PID of the current process in this PID file.

        @raise EnvironmentError: If this PID file cannot be written.
        Nrrrr�writeRunningPIDzIPIDFile.writeRunningPID%rrc��y)zm
        Remove this PID file.

        @raise EnvironmentError: If this PID file cannot be removed.
        Nrrrr�removezIPIDFile.remove,rrc��y)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.
        Nrrrr�	isRunningzIPIDFile.isRunning3rrc��y)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.
        Nrrrr�	__enter__zIPIDFile.__enter__Arrc��y)zS
        Exit a context using this PIDFile.

        Removes the PID file.
        Nr)�excType�excValue�	tracebacks   r�__exit__zIPIDFile.__exit__KrrN��return�int�r%�None�r%�bool)r%z
'IPIDFile')r �Optional[Type[BaseException]]r!�Optional[BaseException]r"�Optional[TracebackType]r%zOptional[bool])
�__name__�
__module__�__qualname__�__doc__rrrrrr#rrrrrsI���	�����	�.�	�)�	�+�	�
�		rrc��eZdZdZe�Zed
d��Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
edd	��Zdd
�Z								dd�Zy)�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�:�t|��d�j�S)z�
        Format a PID file's content.

        @param pid: A process ID.

        @return: Formatted PID file contents.
        �
)r&�encode��pids r�_formatzPIDFile._formatcs���c�(��2��%�%�'�'rc��||_y)zD
        @param filePath: The path to the PID file on disk.
        N)�filePath)�selfr;s  r�__init__zPIDFile.__init__ns��!��
rc�8�d}	|jj�5}|D]}nddd�	t
|�S#1swY�xYw#t$r.}|jtjk(rtd���d}~wwxYw#t$rtd|����wxYw)Nr�PID file does not existz#non-integer PID value in PID file: )	r;�open�OSError�errno�ENOENT�
NoPIDFoundr&�
ValueError�InvalidPIDFileError)r<�	pidString�fh�es    rrzPIDFile.readts����	�	����#�#�%�
��!#��I���
�	��y�>�!�
�
���	��w�w�%�,�,�&� �!:�;�;���	���	�%�5�i�]�C��
�	�s6�A�	;�A�
B�A�A�	A>�)A9�9A>�Bc�Z�|jj|j|���y)z�
        Store a PID in this PID file.

        @param pid: A PID to store.

        @raise EnvironmentError: If this PID file cannot be written.
        r7N)r;�
setContentr9�r<r8s  r�_writezPIDFile._write�s!��	
�
�
� � ����#��!6�7rc�6�|jt��y�N)rMr�r<s rrzPIDFile.writeRunningPID�s�����F�H�rc�8�|jj�yrO)r;rrPs rrzPIDFile.remove�s���
�
���rc��	|j�}tdk(r|j|�St	dt����#t$rYywxYw)NF�posixz isRunning is not implemented on )rrD�SYSTEM_NAME�_pidIsRunningPOSIX�NotImplementedErrorrLs  rrzPIDFile.isRunning�sT��	��)�)�+�C��'�!��*�*�3�/�/�%�(H��
�&V�W�W��
�	��	�s�>�	A
�	A
c���	t|d�y#t$rP}|jtjk(rt	d��|jtj
k(rYd}~y�d}~wwxYw)a1
        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.
        rTz'PID file refers to non-existing processN)rrArB�ESRCH�StalePIDFileError�EPERM)r8rIs  rrUzPIDFile._pidIsRunningPOSIX�sY��"
	���a�L����	��w�w�%�+�+�%�'�(Q�R�R����E�K�K�'����
	�s��	A(�AA#�"A#�#A(c��	|j�r
t��	|j�|S#t$r|jj	d�Y�8wxYw)Nz&Replacing stale PID file: {log_source})r�AlreadyRunningErrorrY�_log�inforrPs rrzPIDFile.__enter__�sW��	E��~�~��)�+�+� �	
�������!�	E��I�I�N�N�C�D�	E�s�/�$A�Ac�$�|j�yrO)r�r<r r!r"s    rr#zPIDFile.__exit__�s��	
���
�rN)r8r&r%�bytes)r;z
FilePath[Any]r%r(r$�r8r&r%r(r'r))r8r&r%r*)r%z	'PIDFile'�r r+r!r,r"r-r%r()r.r/r0r1r
r]�staticmethodr9r=rrMrrrrUrr#rrrr3r3Ws�����8�D��(��(�!��$8���	X�����8��.��*��+�	�

�rr3c�`�eZdZdZdd�Zdd�Zd
d�Zdd�Zdd�Zdd�Z	dd�Z
								dd	�Zy
)�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��yrOrrPs rr=zNonePIDFile.__init__�s��rc��td��)Nr?)rDrPs rrzNonePIDFile.read�s���2�3�3rc�6�ttjd��)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}.
        zOperation not permitted)rArBrZrLs  rrMzNonePIDFile._write�s���e�k�k�#<�=�=rc�&�|jd�y)Nr)rMrPs rrzNonePIDFile.writeRunningPID�s
�����A�rc�6�ttjd��)NzNo such file or directory)rArBrCrPs rrzNonePIDFile.remove�s���e�l�l�$?�@�@rc��y)NFrrPs rrzNonePIDFile.isRunning�s��rc��|SrOrrPs rrzNonePIDFile.__enter__�s���rc��yrOrr`s    rr#zNonePIDFile.__exit__�s��rNr'r$rbr))r%z
'NonePIDFile'rc)r.r/r0r1r=rrMrrrrr#rrrrfrf�sV���
�4�
>��A����.��*��+�	�

�rrf�nonePIDFilec��eZdZdZy)r\z%
    Process is already running.
    N�r.r/r0r1rrrr\r\���rr\c��eZdZdZy)rFz(
    PID file contents are invalid.
    NrqrrrrFrF
rrrrFc��eZdZdZy)rYz[
    PID file contents are valid, but there is no process with the referenced
    PID.
    NrqrrrrYrYs��rrYc��eZdZdZy)rDz#
    No PID found in PID file.
    NrqrrrrDrDrrrrD) r1�
__future__rrB�osrrrrT�typesr�typingrr	r
�zope.interfacerr�twisted.loggerr
�twisted.python.filepathrrr3rfro�__annotations__�	Exceptionr\rFrYrDrrr�<module>rs���
�#��0�0��&�&�1�!�,�?�y�?�D
�X��v�v��v�r
�X��,�,��,�^$�
��X�%��)���)���	����r

Zerion Mini Shell 1.0