Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/uaclient/__pycache__/lock.cpython-310.pyc
o

��pf��@s�ddlZddlZddlZddlmZddlmZmZmZddl	m
Z
mZmZddl
mZddlmZmZddlmZddlmZe�e�e��ZGd	d
�d
e
�Zeeeddd
�ej�Zdeeeffdd�Zdd�Z Gdd�d�Z!dS)�N)�Tuple)�
exceptions�system�util)�
DataObject�Field�StringDataValue)�notices)�DataObjectFile�DataObjectFileFormat)�UAFile)�Noticec@s2eZdZede�ede�gZdedefdd�ZdS)�LockData�lock_pid�lock_holdercCs||_||_dS�N�rr)�selfrr�r�//usr/lib/python3/dist-packages/uaclient/lock.py�__init__s
zLockData.__init__N)�__name__�
__module__�__qualname__rr�fields�strrrrrrrs
�r�lockF)�private�returncCs�zt��}Wntjytjtjd��wd}|s|S|j}|j}zt�	d|g�t
|�|fWStjy\t�
�sKt�d||�t
|�|fYSt�d||�t�tj�|YSw)aReturn lock info if lock file is present the lock is active.

    If process claiming the lock is no longer present, remove the lock file
    and log a warning.

    :return: A tuple (pid, string describing lock holder)
        If no active lock, pid will be -1.
    )�lock_file_path)�����psz.Found stale lock file previously held by %s:%sz1Removing stale lock file previously held by %s:%s)�lock_data_file�readr�InvalidFileFormatError�InvalidLockFile�pathrrr�subp�int�ProcessExecutionErrorr�we_are_currently_root�LOG�debug�warning�ensure_file_absent)�
lock_data_obj�no_lockrrrrr�check_lock_info"s:
����r2cCst��dSr)r#�deleterrrr�clear_lock_file_if_presentLsr4c@sFeZdZdZddd�dededefdd	�Zd
d�Zdd
�Zdd�Z	dS)�	RetryLockah
    Context manager for gaining exclusive access to the lock file.

    Create a lock file if absent. The lock file will contain a pid of the
    running process, and a customer-visible description of the lock holder.

    The RetryLock will try several times to acquire the lock before giving up.
    The number of times to try and how long to sleep in between tries is
    configurable.

    :param lock_holder: String with the service name or command which is
        holding the lock. This lock_holder string will be customer visible in
        status.json.
    :param sleep_time: Number of seconds to sleep before retrying if the lock
        is already held.
    :param max_retries: Maximum number of times to try to grab the lock before
        giving up and raising a LockHeldError.
    :raises: LockHeldError if lock is held after (sleep_time * max_retries)
    �
�)�
sleep_time�max_retriesrr8r9cGs||_||_||_dSr)rr8r9)rrr8r9�_argsrrrres
zRetryLock.__init__cCsVt�\}}|dkrtj|j||d��t�ttt�	��|jd��t
jtj
|jd�dS)Nr)�lock_requestr�pidr)�	operation)r2r�
LockHeldErrorrr#�writerr�os�getpidr	�addr
�OPERATION_IN_PROGRESS)rr�cur_lock_holderrrr�	grab_lockps
��
�zRetryLock.grab_lockc
Cs�t�d|j�d}	z|��WdStjy?}z!t�d|d|j�|d7}||jkr/|�t�	|j
�WYd}~nd}~wwq
)Nzspin lock starting for %srTz%RetryLock Attempt %d. %s. Spinning...�)r,r-rrErr>�msgr9�time�sleepr8)r�tries�errr�	__enter__�s"�
���zRetryLock.__enter__cCst��t�tj�dSr)r#r3r	�remover
rC)r�	_exc_type�
_exc_value�
_tracebackrrr�__exit__�szRetryLock.__exit__N)
rrr�__doc__rr)rrErLrQrrrrr5Ps���
�r5)"�loggingr@rH�typingr�uaclientrrr�uaclient.data_typesrrr�uaclient.filesr	�uaclient.files.data_typesr
r�uaclient.files.filesr�uaclient.files.noticesr
�	getLogger�replace_top_level_logger_namerr,r�JSONr#r)rr2r4r5rrrr�<module>s(
�*

Spamworldpro Mini