Viewing File: /usr/lib/python3.6/site-packages/pip/_vendor/lockfile/__pycache__/__init__.cpython-36.opt-1.pyc
3
�Pf�$ �
@ s� d Z ddlmZ ddlZddlZddlZddlZddlZeed�sJej e_
eejd�sbejjej_
dddd d
ddd
dddddg
ZG dd� de�ZG dd� de�ZG dd� de�ZG dd � d e�ZG dd
� d
e�ZG dd� de�ZG dd� de�ZG dd
� d
e�ZG dd� de�ZG dd� de�Zdd� Zd d� Zd!d� Zd"d� Zd(d#d�Zeed$��rjd%d&l m!Z" e"j#Z$nd%d'l m%Z& e&j'Z$e$Z(dS ))a
lockfile.py - Platform-independent advisory file locks.
Requires Python 2.5 unless you apply 2.4.diff
Locking is done on a per-thread basis instead of a per-process basis.
Usage:
>>> lock = LockFile('somefile')
>>> try:
... lock.acquire()
... except AlreadyLocked:
... print 'somefile', 'is locked already.'
... except LockFailed:
... print 'somefile', 'can\'t be locked.'
... else:
... print 'got lock'
got lock
>>> print lock.is_locked()
True
>>> lock.release()
>>> lock = LockFile('somefile')
>>> print lock.is_locked()
False
>>> with lock:
... print lock.is_locked()
True
>>> print lock.is_locked()
False
>>> lock = LockFile('somefile')
>>> # It is okay to lock twice from the same thread...
>>> with lock:
... lock.acquire()
...
>>> # Though no counter is kept, so you can't unlock multiple times...
>>> print lock.is_locked()
False
Exceptions:
Error - base class for other exceptions
LockError - base class for all locking exceptions
AlreadyLocked - Another thread or process already holds the lock
LockFailed - Lock failed for some other reason
UnlockError - base class for all unlocking exceptions
AlreadyUnlocked - File was not locked.
NotMyLock - File was locked but not by the current thread/process
� )�absolute_importN�current_thread�get_name�Error� LockError�LockTimeout�
AlreadyLocked�
LockFailed�UnlockError� NotLocked� NotMyLock�LinkFileLock�
MkdirFileLock�SQLiteFileLock�LockBase�lockedc @ s e Zd ZdZdS )r zw
Base class for other exceptions.
>>> try:
... raise Error
... except Exception:
... pass
N)�__name__�
__module__�__qualname__�__doc__� r r �/usr/lib/python3.6/__init__.pyr J s c @ s e Zd ZdZdS )r z�
Base class for error arising from attempts to acquire the lock.
>>> try:
... raise LockError
... except Error:
... pass
N)r r r r r r r r r V s c @ s e Zd ZdZdS )r z�Raised when lock creation fails within a user-defined period of time.
>>> try:
... raise LockTimeout
... except LockError:
... pass
N)r r r r r r r r r b s c @ s e Zd ZdZdS )r z�Some other thread/process is locking the file.
>>> try:
... raise AlreadyLocked
... except LockError:
... pass
N)r r r r r r r r r m s c @ s e Zd ZdZdS )r z�Lock file creation failed for some other reason.
>>> try:
... raise LockFailed
... except LockError:
... pass
N)r r r r r r r r r x s c @ s e Zd ZdZdS )r
z�
Base class for errors arising from attempts to release the lock.
>>> try:
... raise UnlockError
... except Error:
... pass
N)r r r r r r r r r
� s c @ s e Zd ZdZdS )r z�Raised when an attempt is made to unlock an unlocked file.
>>> try:
... raise NotLocked
... except UnlockError:
... pass
N)r r r r r r r r r � s c @ s e Zd ZdZdS )r z�Raised when an attempt is made to unlock a file someone else locked.
>>> try:
... raise NotMyLock
... except UnlockError:
... pass
N)r r r r r r r r r � s c @ s>