Your IP : 3.133.153.224


Current Path : /opt/alt/python34/lib64/python3.4/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/multiprocessing/__pycache__/synchronize.cpython-34.pyo

�
e f�/�@s�ddddddgZddlZddlZddlZddlZddlmZd	d
lmZd	dlm	Z	d	dlm
Z
ydd
lmZmZWn*e
k
r�e
dddd��YnXeed��\ZZejjZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dej�ZdS)�Lock�RLock�	Semaphore�BoundedSemaphore�	Condition�Event�N)�time�)�context)�process)�util)�SemLock�
sem_unlinkz*This platform lacks a functioning sem_openz( implementation, therefore, the requiredz+ synchronization primitives needed will notz function, see issue 3770.�c@s�eZdZej�Zdd�Zedd��Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
edd��ZdS)r
c
CsT|dkrtjj�}n|j�}tjdkpB|dk}xbtd�D]H}y,tj||||j	�|�}|_
Wntk
r�YqRXPqRWtd��tj
d|j�|j�tjdkr�dd�}	tj||	�n|j
jdk	rPdd	lm}
|
|j
j�tj|tj|j
jfd
d�ndS)N�win32�fork�dzcannot find name for semaphorezcreated semlock with handle %scSs|jj�dS)N)�_semlock�_after_fork)�obj�r�@/opt/alt/python34/lib64/python3.4/multiprocessing/synchronize.pyrHsz%SemLock.__init__.<locals>._after_forkr	)�registerZexitpriorityr)r
Z_default_contextZget_contextZget_start_method�sys�platform�range�_multiprocessingr
�
_make_namer�FileExistsErrorr�debug�handle�
_make_methodsZregister_after_fork�name�semaphore_trackerrZFinalize�_cleanup)�self�kind�value�maxvalue�ctxr"Z
unlink_now�i�slrrrrr�__init__3s.

zSemLock.__init__cCs(ddlm}t|�||�dS)Nr	)�
unregister)r#r-r)r"r-rrrr$Us
zSemLock._cleanupcCs"|jj|_|jj|_dS)N)r�acquire�release)r%rrrr![szSemLock._make_methodscCs
|jj�S)N)r�	__enter__)r%rrrr0_szSemLock.__enter__cGs|jj|�S)N)r�__exit__)r%�argsrrrr1bszSemLock.__exit__cCsbtj|�|j}tjdkr@tj�j|j�}n	|j}||j|j	|j
fS)Nr)r
�assert_spawningrrrZget_spawning_popenZduplicate_for_childr r&r(r")r%r+�hrrr�__getstate__es
		zSemLock.__getstate__cCs8tjj|�|_tjd|d�|j�dS)Nz recreated blocker with handle %rr)rr
Z_rebuildrrrr!)r%�staterrr�__setstate__nszSemLock.__setstate__cCs$dtj�jdttj�fS)Nz%s-%sZ	semprefix)r�current_processZ_config�nextr
�_randrrrrrsszSemLock._make_nameN)�__name__�
__module__�__qualname__�tempfileZ_RandomNameSequencer:r,�staticmethodr$r!r0r1r5r7rrrrrr
/s"	r
c@s7eZdZddd�Zdd�Zdd�ZdS)	rr	cCs tj|t|td|�dS)Nr))r
r,�	SEMAPHORE�
SEM_VALUE_MAX)r%r'r)rrrr,~szSemaphore.__init__cCs
|jj�S)N)r�
_get_value)r%rrr�	get_value�szSemaphore.get_valuecCs6y|jj�}Wntk
r-d}YnXd|S)N�unknownz<Semaphore(value=%s)>)rrB�	Exception)r%r'rrr�__repr__�s

zSemaphore.__repr__N)r;r<r=r,rCrFrrrrr|sc@s+eZdZddd�Zdd�ZdS)rr	cCs tj|t||d|�dS)Nr))r
r,r@)r%r'r)rrrr,�szBoundedSemaphore.__init__cCsBy|jj�}Wntk
r-d}YnXd||jjfS)NrDz)<BoundedSemaphore(value=%s, maxvalue=%s)>)rrBrEr()r%r'rrrrF�s
zBoundedSemaphore.__repr__N)r;r<r=r,rFrrrrr�sc@s(eZdZdd�Zdd�ZdS)rcCs tj|tddd|�dS)Nr	r))r
r,r@)r%r)rrrr,�sz
Lock.__init__cCs�y�|jj�rStj�j}tj�jdkr�|dtj�j7}q�nB|jj�dkrqd}n$|jj�dkr�d}nd}Wnt	k
r�d}YnXd	|S)
N�
MainThread�|r	�Noner�SomeOtherThread�SomeOtherProcessrDz<Lock(owner=%s)>)
r�_is_minerr8r"�	threading�current_threadrB�_countrE)r%r"rrrrF�s		

z
Lock.__repr__N)r;r<r=r,rFrrrrr�sc@s(eZdZdd�Zdd�ZdS)rcCs tj|tddd|�dS)Nr	r))r
r,�RECURSIVE_MUTEX)r%r)rrrr,�szRLock.__init__cCs�y�|jj�rbtj�j}tj�jdkrP|dtj�j7}n|jj�}nT|jj�dkr�d\}}n0|jj�dkr�d\}}nd
\}}Wnt	k
r�d\}}YnXd
||fS)NrGrHr	rIrrJ�nonzerorKrDz<RLock(%s, %s)>)zNoner)zSomeOtherThreadrQ)zSomeOtherProcessrQ)�unknownrR)
rrLrr8r"rMrNrOrBrE)r%r"�countrrrrF�s
zRLock.__repr__N)r;r<r=r,rFrrrrr�sc@s�eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
dd�Zdd�Zddd�Z
dS)rNcCsY|p|j�|_|jd�|_|jd�|_|jd�|_|j�dS)Nr)r�_lockr�_sleeping_count�_woken_count�_wait_semaphorer!)r%�lockr)rrrr,�s
zCondition.__init__cCs)tj|�|j|j|j|jfS)N)r
r3rTrUrVrW)r%rrrr5�s
zCondition.__getstate__cCs,|\|_|_|_|_|j�dS)N)rTrUrVrWr!)r%r6rrrr7�szCondition.__setstate__cCs
|jj�S)N)rTr0)r%rrrr0�szCondition.__enter__cGs|jj|�S)N)rTr1)r%r2rrrr1�szCondition.__exit__cCs"|jj|_|jj|_dS)N)rTr.r/)r%rrrr!�szCondition._make_methodscCsRy&|jjj�|jjj�}Wntk
r@d}YnXd|j|fS)NrDz<Condition(%s, %s)>)rUrrBrVrErT)r%Znum_waitersrrrrF�s
zCondition.__repr__cCs�|jj�|jjj�}x!t|�D]}|jj�q,Wz|jjd|�SWd|jj�x!t|�D]}|jj�qwWXdS)NT)	rUr/rTrrOrrWr.rV)r%�timeoutrSr*rrr�wait�s

zCondition.waitcCsnx(|jjd�r*|jjd�}qW|jjd�rj|jj�|jj�|jjd�ndS)NF)rVr.rUrWr/)r%�resrrr�notifys

zCondition.notifycCs�x(|jjd�r*|jjd�}qWd}x-|jjd�r`|jj�|d7}q4W|r�x!t|�D]}|jj�qtWx|jjd�r�q�WndS)NFrr	)rVr.rUrWr/r)r%r[Zsleepersr*rrr�
notify_all s
zCondition.notify_allcCs�|�}|r|S|dk	r/t�|}nd}d}xL|s�|dk	rp|t�}|dkrpPqpn|j|�|�}q>W|S)Nr)�_timerZ)r%Z	predicaterY�resultZendtimeZwaittimerrr�wait_for7s		


zCondition.wait_for)r;r<r=r,r5r7r0r1r!rFrZr\r]r`rrrrr�sc@sOeZdZdd�Zdd�Zdd�Zdd�Zd	d
d�Zd	S)rcCs.|j|j��|_|jd�|_dS)Nr)rr�_condr�_flag)r%r)rrrr,OszEvent.__init__c
CsM|jj�z+|jjd�r3|jj�dSdSWd|jj�XdS)NFT)rar.rbr/)r%rrr�is_setSs

zEvent.is_setc
CsP|jj�z.|jjd�|jj�|jj�Wd|jj�XdS)NF)rar.rbr/r])r%rrr�set]s

z	Event.setc
Cs6|jj�z|jjd�Wd|jj�XdS)NF)rar.rbr/)r%rrr�clearfs
zEvent.clearNc
Cs|jj�z]|jjd�r2|jj�n|jj|�|jjd�re|jj�dSdSWd|jj�XdS)NFT)rar.rbr/rZ)r%rYrrrrZms

z
Event.wait)r;r<r=r,rcrdrerZrrrrrMs

	c@s�eZdZdddd�Zdd�Zdd�Zedd	��Zejd
d	��Zedd��Z	e	jd
d��Z	dS)�BarrierNc	Cssddl}ddlm}||jd�d�}|j�}|j|||||f�d|_d|_dS)Nrr	)�
BufferWrapperr*r)�struct�heaprgZcalcsizerr7�_staterO)	r%Zparties�actionrYr)rhrg�wrapperZcondrrrr,�s	zBarrier.__init__cCsC|\|_|_|_|_|_|jj�jd�|_dS)Nr*)�_parties�_action�_timeoutra�_wrapperZcreate_memoryview�cast�_array)r%r6rrrr7�s$zBarrier.__setstate__cCs"|j|j|j|j|jfS)N)rmrnrorarp)r%rrrr5�szBarrier.__getstate__cCs|jdS)Nr)rr)r%rrrrj�szBarrier._statecCs||jd<dS)Nr)rr)r%r'rrrrj�scCs|jdS)Nr	)rr)r%rrrrO�szBarrier._countcCs||jd<dS)Nr	)rr)r%r'rrrrO�s)
r;r<r=r,r7r5�propertyrj�setterrOrrrrrf�s	rf)�__all__rMrr>rrr^�r
rrr
r�ImportError�listrrPr@rA�objectrrrrrrrfrrrr�<module>s0
Mz3

?>