usr/lib/python3.6/site-packages/dnf/__pycache__/lock.cpython-36.pyc000064400000010002147205360560020751 0ustar003 ft`@sddlmZddlmZddlmZmZmZddlmZddl m Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZejdZdd Zd d Zd d ZddZddZGdddeZdS))absolute_import)unicode_literals)ProcessLockErrorThreadLockError LockError)_)miscNdnfcCs6tjjs2tj|jdj}tjj t j d|}|S)Nzutf-8Zlocks) r utilZ am_i_roothashlibZsha1encodeZ hexdigestospathjoinrZ getCacheDir)Zdir_Zhexdirr/usr/lib/python3.6/lock.py _fit_lock_dir&s rcCsttjjt|dd| S)Nzdownload_lock.pidcachedir) ProcessLockr rrr)r exit_on_lockrrrbuild_download_lock/srcCsttjjt|dd| S)Nzmetadata_lock.pidZmetadata)rr rrr)rrrrrbuild_metadata_lock3srcCsttjjt|dd| S)Nzrpmdb_lock.pidZRPMDB)rr rrr)Z persistdirrrrrbuild_rpmdb_lock8srcCsttjjt|dd| S)Nz log_lock.pidlog)rr rrr)Zlogdirrrrrbuild_log_lock=src@s>eZdZdddZddZddZdd Zd d Zd d ZdS)rFcCs&||_d|_||_||_tj|_dS)Nr)blockingcount descriptiontarget threadingRLock thread_lock)selfrrrrrr__init__Cs zProcessLock.__init__cCs2|jjdds 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|tjtjBWn4t k rh}z|j t j krVdSWYdd}~XnXtj |d}t |dkrtj|t|jd|Sy t|}Wn*tk rtd|j}t|YnX||kr|Stjd|tjs*tj|dtjtj|dtj|t|jd|S|Stj|XdS) Nir$rzutf-8zMalformed 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 openrO_CREATO_RDWRfcntlZflockZLOCK_EXZLOCK_NBOSErrorerrnoZ EWOULDBLOCKreadlenwritestrr int ValueErrorrraccessF_OKlseekSEEK_SET ftruncateclose)r"pidfdeZold_pidr&rrr _try_lockPs6     zProcessLock._try_lockcCs|jd8_|jjdS)Nr$)rr!release)r"rrr_unlock_threadzszProcessLock._unlock_threadcCstjjtjj|j|jd}tj}|j |}xp||kr|dkr|j sl|j d|j |f}t ||||krtd|}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 rdirnamerr'getpidr?rrArrrloggerinfotimeZsleep)r"Zprev_pidZmy_pidr<r&rrr __enter__~s"      zProcessLock.__enter__cGs"|jdkrtj|j|jdS)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.yumrZ dnf.loggingr Zdnf.utilr/r-r Zloggingr rrFZ getLoggerrDrrrrrobjectrrrrrs(