%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/beaker/
Upload File :
Create Path :
Current File : //proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyc

�
^��Jc@svdZddlZddlZddlZyddlZWnek
rYddlZnXyej�e	Z
Wn7yddlZeZ
Wq�ek
r�e	Z
q�XnXddl
mZddlmZddddd	gZdefd
��YZej�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
_threadingcBsTeZdZej�Zdefd��YZde	d�Z
ed�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.

    tNLContainercBseZd�Zd�ZRS(cCs+|rtj�|_ntj�|_dS(N(RtRLocktlocktLock(tselft	reentrant((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyt__init__/scCs|jS(N(R	(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyt__call__4s(t__name__t
__module__R
R(((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR.s	cCsC|dkr!tj|�|_ntjj|tj|�|_dS(N(tNoneRRt_locktlockstget(Rt
identifierR((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR
7scCs|j�j|�S(N(Rtacquire(Rtwait((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR>scCs|j�j�dS(N(Rtrelease(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyRAsN(RRt__doc__RtWeakValuedRegistryRtobjectRRtFalseR
tTrueRR(((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR$s	cKstj||f|||�S(N(t_synchronizerstsync_get(Rtclstkwargs((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyt
_synchronizerFscKs1tsd|krt|�St|t|�SdS(Ntlock_dir(t	has_flockRR"tFileSynchronizer(RR!((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyRJs
cKst|t|�S(N(R"tConditionSynchronizer(RR!((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyRQscBs;eZed�Zd�Zd�Zd�ZeZeZRS(cCstS(N(R(RR((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pytacquire_write_lockVscCsdS(N((R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pytacquire_read_lockXscCsdS(N((R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pytrelease_write_lockZscCsdS(N((R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pytrelease_read_lock\s(	RRRR'R(R)R*RR(((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyRUs			tSynchronizerImplcBs�eZd�Zdefd��YZd�Zee�Zd�Zed�Z	d�Z
e
Zed�ZeZ
d�Zd	�Zd
�Zd�ZRS(cCstj�|_dS(N(RtThreadLocalt_state(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR
cst	SyncStatecBseZdZd�ZRS(treentrantcounttwritingtreadingcCsd|_t|_t|_dS(Ni(R/RR0R1(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR
is		(sreentrantcountswritingsreading(RRt	__slots__R
(((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR.fscCs@|jj�s/tj�}|jj|�|S|jj�SdS(N(R-thasR+R.tputR(Rtstate((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR5ns
cCsq|j}|jr!td��n|js9td��n|jdkr^|j�t|_n|jd8_dS(Nslock is in writing stateslock is not in reading statei(R5R0RR1R/tdo_release_read_lockR(RR5((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR*ws			
cCs�|j}|jr!td��n|jdkrj|j|�}|sK|rf|jd7_t|_n|S|jr�|jd7_tSdS(Nslock is in writing stateii(R5R0RR/tdo_acquire_read_lockRR1(RRR5tx((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR(�s			cCsq|j}|jr!td��n|js9td��n|jdkr^|j�t|_n|jd8_dS(Nslock is in reading stateslock is not in writing statei(R5R1RR0R/tdo_release_write_lockR(RR5((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR)�s			
cCs�|j}|jr!td��n|jdkrj|j|�}|sK|rf|jd7_t|_n|S|jr�|jd7_tSdS(Nslock is in reading stateii(R5R1RR/tdo_acquire_write_lockRR0(RRR5R8((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR'�s			cCs
t��dS(N(tNotImplementedError(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR6�scCs
t��dS(N(R;(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR7�scCs
t��dS(N(R;(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR9�scCs
t��dS(N(R;(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR:�s(RRR
RR.R5tpropertyR*RR(R)RR'RR6R7R9R:(((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR+bs							R%cBsbeZdZd�Zd�Zee�Zd�Zd�Zd�Zd�Z	d�Z
d�ZRS(	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.
    
    cCsett|�j�tj�|_|dkr=tj�}n|}tj	||gdd�|_
dS(Nt	extensions.lock(tsuperR%R
RR,t_filedescriptorRttempfilet
gettempdirtencoded_pathtfilename(RRR#((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR
�s	cCs
|jj�S(N(R?R(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyt	_filedesc�scCsA|j}|dkr=tj|j|�}|jj|�n|S(N(RDRtostopenRCR?R4(Rtmodetfiledescriptor((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyt_open�s
	cCs�|jtjtjB�}|ssy"tj|tjtjB�tSWq�t	k
rotj
|�|jj�t
SXntj|tj�tSdS(N(RIREtO_CREATtO_RDONLYtfcntltflocktLOCK_SHtLOCK_NBRtIOErrortcloseR?tremoveR(RRRH((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR7�s


cCs�|jtjtjB�}|ssy"tj|tjtjB�tSWq�t	k
rotj
|�|jj�t
SXntj|tj�tSdS(N(RIRERJtO_WRONLYRLRMtLOCK_EXRORRPRQR?RRR(RRRH((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR:�s


cCs|j�dS(N(t_release_all_locks(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR6scCs|j�dS(N(RU(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR9
scCsI|j}|dk	rEtj|tj�tj|�|jj�ndS(N(	RDRRLRMtLOCK_UNRERQR?RR(RRH((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyRU
s
	
(RRRR
RDR<RIR7R:R6R9RU(((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR%�s							R&cBsAeZdZd�Zed�Zd�Zed�Zd�ZRS(s!a synchronizer using a Condition.cCsAtt|�j�d|_d|_tjtj��|_	dS(Ni(
R>R&R
tasyncRtcurrent_sync_operationRt	ConditionR
t	condition(RR((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR
s		cCs~|jj�zR|r<x6|jdk	r8|jj�qWn|jdk	rOtS|jd7_Wd|jj�X|sztSdS(Ni(	RZRRXRRRRWRR(RR((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR7$s
cCs�|jj�zb|jd8_|jdkrP|jdk	rn|jj�qnn|jdkrntd��nWd|jj�XdS(Niis7Synchronizer error - too many release_read_locks called(RZRRWRXRt	notifyAllRR(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR68s
cCs�|jj�z�|r<x6|jdk	r8|jj�qWn|jdk	rOtStj�|_|jdkr�|r�|jj�q�d|_tSnWd|jj	�X|s�t
SdS(Ni(RZRRXRRRRt
currentThreadRWRR(RR((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR:Js 
	cCs`|jj�z>|jtj�k	r4td��nd|_|jj�Wd|jj�XdS(Ns>Synchronizer error - current thread doesnt have the write lock(	RZRRXRR\RRR[R(R((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR9ns
	(	RRRR
RR7R6R:R9(((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR&s		$(RREtsysR@t	threadingRtImportErrortdummy_threadingtgetwindowsversionRR$RLRtbeakerRtbeaker.exceptionsRt__all__RRRRR"RRRR+R%R&(((sG/opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyt<module>s:




	!			
bQ

Zerion Mini Shell 1.0