Ñò sÖIc@szdZddkZddkZddkZyddkZWnej oddkZnXyeiƒe Z Wn9yddk Z e Z Wq¬ej o e Z q¬XnXddk lZddklZddddd gZdefd „ƒYZeiƒZd „Zd „Zd „Zdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(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(tutil(t LockErrortfile_synchronizertmutex_synchronizertnull_synchronizertNameLockt _threadingcBsTeZdZeiƒZdefd„ƒYZde 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 NLContainercBseZd„Zd„ZRS(cCs-|otiƒ|_ntiƒ|_dS(N(RtRLocktlocktLock(tselft reentrant((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyt__init__/scCs|iS(N(R (R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyt__call__4s(t__name__t __module__R R(((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR.s cCsE|djoti|ƒ|_ntii|ti|ƒ|_dS(N(tNoneRRt_locktlockstget(R t identifierR ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR 7s cCs|iƒi|ƒS(N(Rtacquire(R twait((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR>scCs|iƒiƒdS(N(Rtrelease(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyRAsN(RRt__doc__RtWeakValuedRegistryRtobjectRRtFalseR tTrueRR(((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR$s    cKsti||f|||S(N(t_synchronizerstsync_get(Rtclstkwargs((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyt _synchronizerFscKs4t p d|jo t|ƒSt|t|SdS(Ntlock_dir(t has_flockRR"tFileSynchronizer(RR!((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyRJs cKst|t|S(N(R"tConditionSynchronizer(RR!((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyRQscBs;eZed„Zd„Zd„Zd„ZeZeZRS(cCstS(N(R(R R((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pytacquire_write_lockVscCsdS(N((R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pytacquire_read_lockXscCsdS(N((R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pytrelease_write_lockZscCsdS(N((R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pytrelease_read_lock\s( RRRR'R(R)R*RR(((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyRUs     tSynchronizerImplcBs–eZd„Zdefd„ƒYZd„ZeeƒZd„Zed„Z d„Z e Z ed„Z e Z d„Zd „Zd „Zd „ZRS( cCstiƒ|_dS(N(Rt ThreadLocalt_state(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR cst SyncStatecBseZdZd„ZRS(treentrantcounttwritingtreadingcCsd|_t|_t|_dS(Ni(R/RR0R1(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR is  (sreentrantcountswritingsreading(RRt __slots__R (((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR.fscCsB|iiƒp!tiƒ}|ii|ƒ|S|iiƒSdS(N(R-thasR+R.tputR(R tstate((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR5ns  cCsw|i}|iotdƒ‚n|iptdƒ‚n|idjo|iƒt|_n|id8_dS(Nslock is in writing stateslock is not in reading statei(R5R0RR1R/tdo_release_read_lockR(R R5((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR*ws     cCs“|i}|iotdƒ‚n|idjo>|i|ƒ}|p|o|id7_t|_n|S|io|id7_tSdS(Nslock is in writing stateii(R5R0RR/tdo_acquire_read_lockRR1(R RR5tx((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR(…s    cCsw|i}|iotdƒ‚n|iptdƒ‚n|idjo|iƒt|_n|id8_dS(Nslock is in reading stateslock is not in writing statei(R5R1RR0R/tdo_release_write_lockR(R R5((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR)•s     cCs“|i}|iotdƒ‚n|idjo>|i|ƒ}|p|o|id7_t|_n|S|io|id7_tSdS(Nslock is in reading stateii(R5R1RR/tdo_acquire_write_lockRR0(R RR5R8((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR'¥s    cCs tƒ‚dS(N(tNotImplementedError(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR6·scCs tƒ‚dS(N(R;(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR7ºscCs tƒ‚dS(N(R;(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR9½scCs tƒ‚dS(N(R;(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR:Às(RRR RR.R5tpropertyR*RR(R)RR'RR6R7R9R:(((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR+bs          R%cBsbeZdZd„Zd„ZeeƒZd„Zd„Zd„Zd„Z d„Z d„Z RS( sa 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. cCsgtt|ƒiƒtiƒ|_|djotiƒ}n|}ti ||gddƒ|_ dS(Nt extensions.lock( tsuperR%R RR,t_filedescriptorRttempfilet gettempdirt encoded_pathtfilename(R RR#((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR Ñs  cCs |iiƒS(N(R?R(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyt _filedescàscCs=|i}|p)ti|i|ƒ}|ii|ƒn|S(N(RDtostopenRCR?R4(R tmodetfiledescriptor((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyt_openäs  cCs’|ititiBƒ}|pWy"ti|titiBƒtSWqŽt j o"ti |ƒ|i i ƒt SXnti|tiƒtSdS(N(RIREtO_CREATtO_RDONLYtfcntltflocktLOCK_SHtLOCK_NBRtIOErrortcloseR?tremoveR(R RRH((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR7ës   cCs’|ititiBƒ}|pWy"ti|titiBƒtSWqŽt j o"ti |ƒ|i i ƒt SXnti|tiƒtSdS(N(RIRERJtO_WRONLYRLRMtLOCK_EXRORRPRQR?RRR(R RRH((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR:ùs   cCs|iƒdS(N(t_release_all_locks(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR6scCs|iƒdS(N(RU(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR9 scCsE|i}|o1ti|tiƒti|ƒ|iiƒndS(N(RDRLRMtLOCK_UNRERQR?RR(R RH((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyRU s   ( RRRR RDR<RIR7R:R6R9RU(((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR%Äs         R&cBsAeZdZd„Zed„Zd„Zed„Zd„ZRS(s!a synchronizer using a Condition.cCsAtt|ƒiƒd|_d|_titiƒƒ|_ dS(Ni( R>R&R tasyncRtcurrent_sync_operationRt ConditionR t condition(R R((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR s  cCs†|iiƒzX|o)x;|idj o|iiƒqWn|idj otS|id7_Wd|iiƒX|ptSdS(Ni( RZRRXRRRRWRR(R R((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR7$s cCsŠ|iiƒzh|id8_|idjo%|idj o|iiƒqtn!|idjotdƒ‚nWd|iiƒXdS(Niis7Synchronizer error - too many release_read_locks called(RZRRWRXRt notifyAllRR(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR68s cCs¿|iiƒz‘|o)x;|idj o|iiƒqWn|idj otStiƒ|_|idjo)|o|iiƒqd|_tSnWd|ii ƒX|pt SdS(Ni( RZRRXRRRRt currentThreadRWRR(R R((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR:Js"   cCsb|iiƒz@|itiƒj otdƒ‚nd|_|iiƒWd|iiƒXdS(Ns>Synchronizer error - current thread doesnt have the write lock( RZRRXRR\RRR[R(R ((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR9ns  ( RRRR RR7R6R:R9(((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyR&s    $(RREtsysR@t threadingRt ImportErrortdummy_threadingtgetwindowsversionRR$RLRtbeakerRtbeaker.exceptionsRt__all__RRRRR"RRRR+R%R&(((s:/usr/lib/python2.6/site-packages/beaker/synchronization.pyts:         !     bQ