Ñò sÖIc @ sz d Z d d k Z d d k Z d d k Z y d d k Z Wn e j o d d k Z n Xy e i ƒ e Z Wn9 y d d k Z e Z Wq¬ e j o e Z q¬ Xn Xd d k l Z d d k l Z d d d d d g Z d e f d „ ƒ YZ e i ƒ Z d „ Z d „ Z d „ Z d e f d „ ƒ YZ d e f d „ ƒ YZ d e f d „ ƒ YZ d e f d „ ƒ YZ d S( s¸ Synchronization functions. File- and mutex-based mutual exclusion synchronizers are provided, as well as a name-based mutex which locks within an application based on a string name. iÿÿÿÿN( t util( t LockErrort file_synchronizert mutex_synchronizert null_synchronizert NameLockt _threadingc B sT e Z d Z e i ƒ Z d e f d „ ƒ YZ d e d „ Z e d „ Z d „ Z RS( sÞ a proxy for an RLock object that is stored in a name based registry. Multiple threads can get a reference to the same RLock based on the name alone, and synchronize operations related to that name. t NLContainerc B s e Z d „ Z d „ Z RS( c C s- | o t i ƒ | _ n t i ƒ | _ d S( N( R t RLockt lockt Lock( t selft reentrant( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt __init__/ s c C s | i S( N( R ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt __call__4 s ( t __name__t __module__R R ( ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR . s c C sE | d j o t i | ƒ | _ n t i i | t i | ƒ | _ d S( N( t NoneR R t _lockt lockst get( R t identifierR ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR 7 s c C s | i ƒ i | ƒ S( N( R t acquire( R t wait( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR > s c C s | i ƒ i ƒ d S( N( R t release( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR A s N( R R t __doc__R t WeakValuedRegistryR t objectR R t FalseR t TrueR R ( ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR $ s c K s t i | | f | | | S( N( t _synchronizerst sync_get( R t clst kwargs( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt _synchronizerF s c K s4 t p d | j o t | ƒ St | t | Sd S( Nt lock_dir( t has_flockR R" t FileSynchronizer( R R! ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR J s c K s t | t | S( N( R" t ConditionSynchronizer( R R! ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR Q s c B s; e Z e d „ Z d „ Z d „ Z d „ Z e Z e Z RS( c C s t S( N( R ( R R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt acquire_write_lockV s c C s d S( N( ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt acquire_read_lockX s c C s d S( N( ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt release_write_lockZ s c C s d S( N( ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt release_read_lock\ s ( R R R R' R( R) R* R R ( ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR U s t SynchronizerImplc B s– e Z d „ Z d e f d „ ƒ YZ d „ Z e e ƒ Z d „ Z e d „ Z d „ Z e Z e d „ Z e Z d „ Z d „ Z d „ Z d „ Z RS( c C s t i ƒ | _ d S( N( R t ThreadLocalt _state( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR c s t SyncStatec B s e Z d Z d „ Z RS( t reentrantcountt writingt readingc C s d | _ t | _ t | _ d S( Ni ( R/ R R0 R1 ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR i s ( s reentrantcounts writings reading( R R t __slots__R ( ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR. f s c C sB | i i ƒ p! t i ƒ } | i i | ƒ | S| i i ƒ Sd S( N( R- t hasR+ R. t putR ( R t state( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR5 n s c C sw | i } | i o t d ƒ ‚ n | i p t d ƒ ‚ n | i d j o | i ƒ t | _ n | i d 8_ d S( Ns lock is in writing states lock is not in reading statei ( R5 R0 R R1 R/ t do_release_read_lockR ( R R5 ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR* w s c C s“ | i } | i o t d ƒ ‚ n | i d j o> | i | ƒ } | p | o | i d 7_ t | _ n | S| i o | i d 7_ t Sd S( Ns lock is in writing statei i ( R5 R0 R R/ t do_acquire_read_lockR R1 ( R R R5 t x( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR( … s c C sw | i } | i o t d ƒ ‚ n | i p t d ƒ ‚ n | i d j o | i ƒ t | _ n | i d 8_ d S( Ns lock is in reading states lock is not in writing statei ( R5 R1 R R0 R/ t do_release_write_lockR ( R R5 ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR) • s c C s“ | i } | i o t d ƒ ‚ n | i d j o> | i | ƒ } | p | o | i d 7_ t | _ n | S| i o | i d 7_ t Sd S( Ns lock is in reading statei i ( R5 R1 R R/ t do_acquire_write_lockR R0 ( R R R5 R8 ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR' ¥ s c C s t ƒ ‚ d S( N( t NotImplementedError( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR6 · s c C s t ƒ ‚ d S( N( R; ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR7 º s c C s t ƒ ‚ d S( N( R; ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR9 ½ s c C s t ƒ ‚ d S( N( R; ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR: À s ( R R R R R. R5 t propertyR* R R( R) R R' R R6 R7 R9 R: ( ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR+ b s R% c B sb e Z d Z d „ Z d „ Z e e ƒ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( s a synchronizer which locks using flock(). Adapted for Python/multithreads from Apache::Session::Lock::File, http://search.cpan.org/src/CWEST/Apache-Session-1.81/Session/Lock/File.pm This module does not unlink temporary files, because it interferes with proper locking. This can cause problems on certain systems (Linux) whose file systems (ext2) do not perform well with lots of files in one directory. To prevent this you should use a script to clean out old files from your lock directory. c C sg t t | ƒ i ƒ t i ƒ | _ | d j o t i ƒ } n | } t i | | g d d ƒ| _ d S( Nt extensions .lock( t superR% R R R, t _filedescriptorR t tempfilet gettempdirt encoded_patht filename( R R R# ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR Ñ s c C s | i i ƒ S( N( R? R ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt _filedescà s c C s= | i } | p) t i | i | ƒ } | i i | ƒ n | S( N( RD t ost openRC R? R4 ( R t modet filedescriptor( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyt _openä s c C s’ | i t i t i Bƒ } | pW y" t i | t i t i Bƒ t SWqŽ t j o" t i | ƒ | i i ƒ t SXn t i | t i ƒ t Sd S( N( RI RE t O_CREATt O_RDONLYt fcntlt flockt LOCK_SHt LOCK_NBR t IOErrort closeR? t removeR ( R R RH ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR7 ë s c C s’ | i t i t i Bƒ } | pW y" t i | t i t i Bƒ t SWqŽ t j o" t i | ƒ | i i ƒ t SXn t i | t i ƒ t Sd S( N( RI RE RJ t O_WRONLYRL RM t LOCK_EXRO R RP RQ R? RR R ( R R RH ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR: ù s c C s | i ƒ d S( N( t _release_all_locks( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR6 s c C s | i ƒ d S( N( RU ( R ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyR9 s c C sE | i } | o1 t i | t i ƒ t i | ƒ | i i ƒ n d S( N( RD RL RM t LOCK_UNRE RQ R? RR ( R RH ( ( s: /usr/lib/python2.6/site-packages/beaker/synchronization.pyRU s ( R R R R RD R<