Repository URL to install this package:
|
Version:
3.3.30 ▾
|
ó
ìEYc @ sõ d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z e j e Z
d Z d e f d YZ
d e
f d YZ d e
f d YZ e j d
k rÖ d d l Z e Z n d d l Z e Z d Z d S( iÿÿÿÿN( t _utilsc C sy y t j | Wn] t k
rp } | j t j k rT t j j | sM qm t Squ | j t j k rj t S n Xt Sd S( sf Create a directory (and any ancestor directories required).
:param path: Directory to create
N(
t ost makedirst OSErrort errnot EEXISTt patht isdirt Falset EISDIRt True( R t e( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/fasteners/process_lock.pyt _ensure_tree s t _InterProcessLockc B s e Z d Z d Z d Z e j d d Z d Z d Z
e e e d d Z d Z
d Z d Z d
Z d Z d Z d
Z RS( sT An interprocess locking implementation.
This is a lock implementation which allows multiple locks, working around
issues like http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=632857 and
does not require any cleanup. Since the lock is always held on a file
descriptor rather than outside of the process, the lock gets dropped
automatically if the process crashes, even if ``__exit__`` is not
executed.
There are no guarantees regarding usage by multiple threads in a
single process here. This lock works only between processes.
Note these locks are released when the descriptor is closed, so it's not
safe to close the file descriptor while another thread holds the
lock. Just opening and closing the lock file can break synchronization,
so lock files must be accessed only using this abstraction.
g¹?g{®Gáz?c C s= d | _ | | _ t | _ | | _ t j | t | _ d S( N(
t Nonet lockfileR R t acquiredt
sleep_funcR t pick_first_not_nonet LOGt logger( t selfR R R ( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/fasteners/process_lock.pyt __init__U s
c C s y | j Wnx t k
r } | j t j t j f k ra | sN | j rR t St j q t j
d i | j d 6| d 6 n Xt Sd S( Ns9 Unable to acquire lock on `%(path)s` due to %(exception)sR t exception(
t trylockt IOErrorR t EACCESt EAGAINt expiredR R t
RetryAgaint threadingt ThreadErrorR R
( R t blockingt watchR ( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/fasteners/process_lock.pyt _try_acquire\ s
c C s t j j | j } | rL t | } | rL | j j t j d | qL n | j d k sg | j j
r t | j d | _ n d S( Ns Created lock base path `%s`t a( R R t dirnameR R t logR t BLATHERR R t closedt open( R t basedirt made_basedir( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/fasteners/process_lock.pyt _do_openp s c C s | d k r t d n | d k rB | d k rB t d n | | k rW | } n | j t j d | } t j | | d | j d | } | | | j | | } Wd QX| sÉ t | _ t St
| _ | j j t j
d | j | j | j t
Sd S( sö Attempt to acquire the given lock.
:param blocking: whether to wait forever to try to acquire the lock
:type blocking: bool
:param delay: when blocking this is the delay time in seconds that
will be added after each failed acquisition
:type delay: int/float
:param max_delay: the maximum delay to have (this limits the
accumulated delay(s) added after each failed
acquisition)
:type max_delay: int/float
:param timeout: an optional timeout (limits how long blocking
will occur for)
:type timeout: int/float
:returns: whether or not the acquisition succeeded
:rtype: bool
i s+ Delay must be greater than or equal to zeros- Timeout must be greater than or equal to zerot durationR R! NsH Acquired file lock `%s` after waiting %0.3fs [%s attempts were required]( t
ValueErrorR R+ R t StopWatcht RetryR R" R R R
R R% R&