Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/lockfile/__pycache__/ |
Upload File : |
o ��UV\ � @ sP d dl mZ d dlZd dlZddlmZmZmZmZm Z m Z G dd� de�ZdS )� )�absolute_importN� )�LockBase� LockFailed� NotLocked� NotMyLock�LockTimeout� AlreadyLockedc @ s: e Zd ZdZd dd�Zdd� Zdd� Zd d � Zdd� ZdS )�LinkLockFilez�Lock access to a file using atomic property of link(2). >>> lock = LinkLockFile('somefile') >>> lock = LinkLockFile('somefile', threaded=False) Nc C s z t | jd��� W n ty td| j ��w |d ur|n| j}t�� }|d ur2|dkr2||7 } zt�| j| j � W d S t y� t�| j�j}|dkrSY d S |d urut�� |krut� | j� |dkrntd| j ��td| j ��t�|d ur|d p�d � Y nw q3) N�wbzfailed to create %sr T� z&Timeout waiting to acquire lock for %sz%s is already locked� g�������?)�open�unique_name�close�IOErrorr �timeout�time�os�link� lock_file�OSError�stat�st_nlink�unlinkr �pathr �sleep)�selfr �end_time�nlinks� r �7/usr/lib/python3/dist-packages/lockfile/linklockfile.py�acquire s: ������zLinkLockFile.acquirec C sN | � � std| j ��tj�| j�std| j ��t�| j� t�| j� d S )Nz%s is not lockedz%s is locked, but not by me) � is_lockedr r r �existsr r r r �r r r r! �release7 s zLinkLockFile.releasec C s t j�| j�S �N)r r r$ r r% r r r! r# ? s zLinkLockFile.is_lockedc C s( | � � otj�| j�ot�| j�jdkS )Nr )r# r r r$ r r r r% r r r! �i_am_lockingB s ��zLinkLockFile.i_am_lockingc C s"