AlkantarClanX12

Your IP : 3.12.161.151


Current Path : /usr/lib/python3.6/site-packages/dnf/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dnf/__pycache__/lock.cpython-36.pyc

3

�ft`��@s�ddlmZddlmZddlmZmZmZddlmZddl	m
Z
ddlZddl
ZddlZddlZddlZddlZddlZddlZddlZejd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�ZGdd�de�ZdS)�)�absolute_import)�unicode_literals)�ProcessLockError�ThreadLockError�	LockError)�_)�miscN�dnfcCs6tjj�s2tj|jd��j�}tjj	t
j�d|�}|S)Nzutf-8Zlocks)r	�utilZ	am_i_root�hashlibZsha1�encodeZ	hexdigest�os�path�joinrZgetCacheDir)Zdir_Zhexdir�r�/usr/lib/python3.6/lock.py�
_fit_lock_dir&s
rcCsttjjt|�d�d|�S)Nzdownload_lock.pid�cachedir)�ProcessLockr
rrr)r�exit_on_lockrrr�build_download_lock/srcCsttjjt|�d�d|�S)Nzmetadata_lock.pidZmetadata)rr
rrr)rrrrr�build_metadata_lock3srcCsttjjt|�d�d|�S)Nzrpmdb_lock.pidZRPMDB)rr
rrr)Z
persistdirrrrr�build_rpmdb_lock8srcCsttjjt|�d�d|�S)Nzlog_lock.pid�log)rr
rrr)Zlogdirrrrr�build_log_lock=src@s>eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rFcCs&||_d|_||_||_tj�|_dS)Nr)�blocking�count�description�target�	threading�RLock�thread_lock)�selfrrrrrr�__init__Cs
zProcessLock.__init__cCs2|jjdd�s d|j}t|��|jd7_dS)NF)rz'%s already locked by a different thread�)r!�acquirerrr)r"�msgrrr�_lock_threadJs
zProcessLock._lock_threadc Cs>tj|jtjtjBd�}�zytj|tjtjB�Wn4t	k
rh}z|j
t
jkrVdS�WYdd}~XnXtj|d�}t
|�dkr�tj|t|�jd��|Syt|�}Wn*tk
r�td�|j}t|��YnX||kr�|Stjd|tj��s*tj|dtj�tj|d�tj|t|�jd��|S|Stj|�XdS)	Ni�r$�rzutf-8z�Malformed lock file found: %s.
Ensure no other dnf/yum process is running and remove the lock file manually or run systemd-tmpfiles --remove dnf.conf.z
/proc/%d/stat���)r
�openr�O_CREAT�O_RDWR�fcntlZflockZLOCK_EXZLOCK_NB�OSError�errnoZEWOULDBLOCK�read�len�write�strr�int�
ValueErrorrr�access�F_OK�lseek�SEEK_SET�	ftruncate�close)r"�pid�fd�eZold_pidr&rrr�	_try_lockPs6zProcessLock._try_lockcCs|jd8_|jj�dS)Nr$)rr!�release)r"rrr�_unlock_threadzszProcessLock._unlock_threadcCs�tjjtjj|j��|j�d}tj�}|j	|�}xp||kr�|dkr�|j
sl|j�d|j|f}t
||��||kr�td�|}tj|�|}tjd�|j	|�}q6WdS)Nr$z%s already locked by %dz*Waiting for process with pid %d to finish.r)r))r	r
Z
ensure_dirr
r�dirnamerr'�getpidr?rrArrr�logger�info�timeZsleep)r"Zprev_pidZmy_pidr<r&rrr�	__enter__~s"




zProcessLock.__enter__cGs"|jdkrtj|j�|j�dS)Nr$)rr
�unlinkrrA)r"Zexc_argsrrr�__exit__�s
zProcessLock.__exit__N)F)	�__name__�
__module__�__qualname__r#r'r?rArGrIrrrrrBs
*r)Z
__future__rrZdnf.exceptionsrrrZdnf.i18nrZdnf.yumrZdnf.loggingr	Zdnf.utilr/r-rZloggingr
rrFZ	getLoggerrDrrrrr�objectrrrrr�<module>s(