HEX
Server: Apache
System: Linux a16-asgard6.hospedagemuolhost.com.br 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: maoristu4c3dbd03 (1436)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/rhn/__pycache__/rhnLockfile.cpython-39.opt-1.pyc
a

U��Zc
�@s~ddlZddlZddlZddlmZmZddlmZddlZGdd�de�Z	Gdd�d�Z
dd	�Zed
krze�
e�pvd�dS)�N)�EWOULDBLOCK�EEXIST)�bstrc@seZdZdZdS)�LockfileLockedExceptionz$thrown ONLY when pid file is locked.N)�__name__�
__module__�__qualname__�__doc__�r
r
�3/usr/lib/python3.9/site-packages/rhn/rhnLockfile.pyrsrc@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�Lockfilez�class that provides simple access to a PID-style lockfile.

    methods: __init__(lockfile), acquire(), and release()
    NOTE: currently acquires upon init
    The *.pid file will be acquired, or an LockfileLockedException is raised.
    NcCs�tj�tj�tj�|���|_||_|js4t��|_tj�|j�}tj�	|�s�zt�
|�Wn6ty�t�
�d}t|d�r�|jtkr�n�Yn0t�|jtjtjBtjB�|_|��dS)zlcreate (if need be), and acquire lock on lockfile

        lockfile example: '/var/run/up2date.pid'
        ��errnoN)�os�path�abspath�
expanduser�
expandvars�lockfile�pid�getpid�dirname�exists�makedirs�OSError�sys�exc_info�hasattrrr�open�O_RDWR�O_CREAT�O_SYNC�f�acquire)�selfrrr�er
r
r�__init__$s&
��
zLockfile.__init__cCs�zt�|jtjtjB�WnBty\t��djt	krVt
d|jdt��d��n�Yn0t�|jtjd�t
�|jd�t
�|jtt|j�d��dS)z5acquire the lock; else raise LockfileLockedException.r
zcannot acquire lock on %s.N�r�
)�fcntl�flockr"ZLOCK_EXZLOCK_NB�IOErrorrrrrrrZF_SETFDr�	ftruncate�writer�strr�r$r
r
rr#Es�zLockfile.acquirecCs,t�|j�t�|jtj�t�|j�dS)N)r�unlinkrr)r*r"ZLOCK_UN�closer/r
r
r�releaseVszLockfile.release)N)rrrr	r&r#r2r
r
r
rrs
!rcCsxztd�}Wn4ty@tj�dt��d�t�d�Yn40td�td�ddl}|�	d	�|�
�td
�dS)z	test codez
./test.pidz%s
r
���zlock acquired z...sleeping for 10 secondsrN�
zlock released )rrr�stderrr-r�exit�print�time�sleepr2)�Lr8r
r
r�main]s
r;�__main__)rrr)rrrZrhn.i18nr�	Exceptionrrr;rr6r
r
r
r�<module>sB