ok
Direktori : /opt/imunify360/venv/lib/python3.11/site-packages/lockfile/__pycache__/ |
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/lockfile/__pycache__/pidlockfile.cpython-311.pyc |
� >�Dg� � �| � d Z ddlmZ ddlZddlZddlZddlmZmZm Z m Z mZmZ G d� de� � Z d� Zd � Zd � ZdS )z8 Lockfile behaviour implemented via Unix PID files. � )�absolute_importN� )�LockBase� AlreadyLocked� LockFailed� NotLocked� NotMyLock�LockTimeoutc �@ � e Zd ZdZdd�Zd� Zd� Zd� Zdd�Zd � Z d � Z dS ) �PIDLockFileaA Lockfile implemented as a Unix PID file. The lock file is a normal file named by the attribute `path`. A lock's PID file contains a single line of text, containing the process ID (PID) of the process that acquired the lock. >>> lock = PIDLockFile('somefile') >>> lock = PIDLockFile('somefile') FNc �L � t j | |d|� � | j | _ d S )NF)r �__init__�path�unique_name)�selfr �threaded�timeouts �K/opt/imunify360/venv/lib64/python3.11/site-packages/lockfile/pidlockfile.pyr zPIDLockFile.__init__$ s+ � � ��$��e�W�5�5�5��9����� c �* � t | j � � S )z- Get the PID from the lock file. )�read_pid_from_pidfiler �r s r �read_pidzPIDLockFile.read_pid* s � � %�T�Y�/�/�/r c �J � t j � | j � � S )zv Test if the lock is currently held. The lock is held if the PID file for this lock exists. )�osr �existsr s r � is_lockedzPIDLockFile.is_locked/ s � � �w�~�~�d�i�(�(�(r c �| � | � � � o(t j � � | � � � k S )z� Test if the lock is held by the current process. Returns ``True`` if the current process ID matches the number stored in the PID file. )r r �getpidr r s r �i_am_lockingzPIDLockFile.i_am_locking7 s, � � �~�~���B�B�I�K�K�4�=�=�?�?�$B�Br c �� � |�|n| j }t j � � }|�|dk r||z } t | j � � dS # t $ r�}|j t j k rkt j � � |k r6|�|dk rt d| j z � � �t d| j z � � �t j |dur|dz pd� � nt d| j z � � �Y d}~nd}~ww xY w��) z� Acquire the lock. Creates the PID file for this lock, or raises an error if the lock could not be acquired. Nr Tz&Timeout waiting to acquire lock for %sz%s is already locked� g�������?zfailed to create %s)r �time�write_pid_to_pidfiler �OSError�errno�EEXISTr r �sleepr )r r �end_time�excs r �acquirezPIDLockFile.acquire? s@ � � %�0�'�'�d�l���9�;�;����7�Q�;�;����H� � �$�T�Y�/�/�/� ��� � H� H� H��9���,�,��y�{�{�X�-�-�"�.�7�Q�;�;�"-� /=�.2�i�/8� #9� #9� 9� #0�0F�04� �1:� #;� #;� ;��J�w�d�2�C�w��|�J�s�K�K�K�K�$�%:�T�Y�%F�G�G�G� L�K�K�K�K����� H���� s �A � C/�BC*�*C/c �� � | � � � st d| j z � � �| � � � st d| j z � � �t | j � � dS )z� Release the lock. Removes the PID file to release the lock, or raises an error if the current process does not hold the lock. z%s is not lockedz%s is locked, but not by meN)r r r r r �remove_existing_pidfiler s r �releasezPIDLockFile.release_ sm � � �~�~��� <��.���:�;�;�;�� � �"�"� G��9�D�I�E�F�F�F��� �*�*�*�*�*r c �. � t | j � � dS )z� Break an existing lock. Removes the PID file if it already exists, otherwise does nothing. N)r- r r s r � break_lockzPIDLockFile.break_lockl s � � �� �*�*�*�*�*r )FN)N)�__name__� __module__�__qualname__�__doc__r r r r r+ r. r0 � r r r r s� � � � � � �� �%� %� %� %�0� 0� 0� )� )� )�C� C� C�� � � �@+� +� +�+� +� +� +� +r r c � � d} t | d� � }|� � � � � � } t |� � }n# t $ r Y nw xY w|� � � n# t $ r Y nw xY w|S )z� Read the PID recorded in the named PID file. Read and return the numeric PID recorded as text in the named PID file. If the PID file cannot be read, or if the content is not a valid PID, return ``None``. N�r)�open�readline�strip�int� ValueError�close�IOError)�pidfile_path�pid�pidfile�lines r r r v s� � � �C���|�S�)�)�� ���!�!�'�'�)�)�� ��d�)�)�C�C��� � � ��D� ����� � ������% � � � ��� ����( �Js"