File: //lib/python3.9/site-packages/rhn/__pycache__/rhnLockfile.cpython-39.pyc
a
U��Zc
� @ s~ d dl Z d dlZd dlZd dlmZmZ d dlmZ d dlZG dd� de�Z G dd� d�Z
dd � Zed
krze�
e� pvd � dS )� N)�EWOULDBLOCK�EEXIST)�bstrc @ s e Zd ZdZdS )�LockfileLockedExceptionz$thrown ONLY when pid file is locked.N)�__name__�
__module__�__qualname__�__doc__� r
r
�3/usr/lib/python3.9/site-packages/rhn/rhnLockfile.pyr s r c @ s* e Zd ZdZd 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.
Nc C s� t j�t j�t j�|���| _|| _| js4t �� | _t j�| j�}t j� |�s�zt �
|� W n6 ty� t�
� d }t|d�r�|jtkr�n� Y n0 t �| jt jt jB t jB �| _| �� 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�hasattrr r �open�O_RDWR�O_CREAT�O_SYNC�f�acquire)�selfr r r �er
r
r �__init__$ s&