File: //usr/lib/python3/dist-packages/twisted/python/__pycache__/lockfile.cpython-310.pyc
o
�bZ � @ s� d Z ddlZddlZddlmZ ddlmZ dd� ZddlmZ e� � s3ddlm
Z
mZmZ
mZ d Zn0d
ZzddlZddlmZ W n eyL dZ
Y n w dZd
Zdd� Z
eZdd� Zdd� Zdd� Z
G dd� d�Zdd� ZddgZdS )z&
Filesystem-based interprocess mutex.
� N)�time)�platformc C s t tt� d ��S )Ni� )�str�int�_uniquefloat� r r �9/usr/lib/python3/dist-packages/twisted/python/lockfile.py�unique s r )�rename)�kill�readlink�remove�symlinkFT)�OpenProcess� �W c
C sj zt dd| � W t d�� tjy4 } z|jd tkr"W Y d }~d S |jd tkr/ttjd ��� d }~ww )Nr z OpenProcess is required to fail.)
r �
pywintypes�error�args�ERROR_ACCESS_DENIED�ERROR_INVALID_PARAMETER�OSError�errno�ESRCH�RuntimeError)�pid�signal�er r r r 4 s ���r c C s� |d t � d }tj�|d�}t�|� d}t||��}|�| � |�� W d � n1 s0w Y zt||� W dS t yO t�
|� t�|� � w )z�
Write a file at C{filename} with the contents of C{value}. See the
above comment block as to why this is needed.
�.z.newlinkr �wN)r �os�path�join�mkdir�_open�write�flushr
�
BaseExceptionr
�rmdir)�value�filename�newlinkname�
newvalname�mode�fr r r r E s
�
�r c
C s� zt tj�| d�d�}W n ty+ } z|jtjks |jtjkr&t|jd��� d}~ww |�
|�� }W d � |S 1 s>w Y |S )zq
Read the contents of C{filename}. See the above comment block as to why
this is needed.
r �rN) r$ r r! r"