Your IP : 18.227.46.54


Current Path : /opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/synchronize.cpython-35.opt-1.pyc



��Yf/�@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
CsK|dkrtjj�}|j�}tjdkp?|dk}xbtd�D]H}y,tj||||j	�|�}|_
Wntk
r�YqOXPqOWtd��tj
d|j�|j�tjdkr�dd�}	tj||	�|j
jdk	rGdd	lm}
|
|j
j�tj|tj|j
jfd
d�dS)N�win32�fork�dzcannot find name for semaphorezcreated semlock with handle %scSs|jj�dS)N)�_semlock�_after_fork)�obj�r�@/opt/alt/python35/lib64/python3.5/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_valuecCsBy|jj�}Wntk
r-d}YnXd|jj|fS)N�unknownz<%s(value=%s)>)rrB�	Exception�	__class__r;)r%r'rrr�__repr__�s

zSemaphore.__repr__N)r;r<r=r,rCrGrrrrr|sc@s+eZdZddd�Zdd�ZdS)rr	cCs tj|t||d|�dS)Nr))r
r,r@)r%r'r)rrrr,�szBoundedSemaphore.__init__cCsKy|jj�}Wntk
r-d}YnXd|jj||jjfS)NrDz<%s(value=%s, maxvalue=%s)>)rrBrErFr;r()r%r'rrrrG�s
zBoundedSemaphore.__repr__N)r;r<r=r,rGrrrrr�sc@s(eZdZdd�Zdd�ZdS)rcCs tj|tddd|�dS)Nr	r))r
r,r@)r%r)rrrr,�sz
Lock.__init__cCs�y�|jj�rPtj�j}tj�jdkr�|dtj�j7}nB|jj�dkrnd}n$|jj�dkr�d}nd}Wnt	k
r�d}YnXd	|j
j|fS)
N�
MainThread�|r	�Noner�SomeOtherThread�SomeOtherProcessrDz<%s(owner=%s)>)r�_is_minerr8r"�	threading�current_threadrB�_countrErFr;)r%r"rrrrG�s		

z
Lock.__repr__N)r;r<r=r,rGrrrrr�sc@s(eZdZdd�Zdd�ZdS)rcCs tj|tddd|�dS)Nr	r))r
r,�RECURSIVE_MUTEX)r%r)rrrr,�szRLock.__init__cCs�y�|jj�r_tj�j}tj�jdkrM|dtj�j7}|jj�}nT|jj�dkr�d\}}n0|jj�dkr�d\}}nd
\}}Wnt	k
r�d\}}YnXd
|j
j||fS)NrHrIr	rJrrK�nonzerorLrDz<%s(%s, %s)>)rJr)rKrR)rLrR)rDrD)rrMrr8r"rNrOrPrBrErFr;)r%r"�countrrrrG�s
zRLock.__repr__N)r;r<r=r,rGrrrrr�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_methodscCs[y&|jjj�|jjj�}Wntk
r@d}YnXd|jj|j|fS)NrDz<%s(%s, %s)>)rUrrBrVrErFr;rT)r%Znum_waitersrrrrG�s
zCondition.__repr__cCs�|jj�|jjj�}x!t|�D]}|jj�q,Wz|jjd|�SWd|jj�x!t|�D]}|jj�qwWXdS)NT)	rUr/rTrrPrrWr.rV)r%�timeoutrSr*rrr�wait�s

zCondition.waitcCskx(|jjd�r*|jjd�}qW|jjd�rg|jj�|jj�|jjd�dS)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�WdS)NFrr	)rVr.rUrWr/r)r%r[Zsleepersr*rrr�
notify_all s
zCondition.notify_allcCs�|�}|r|S|dk	r/t�|}nd}d}xF|s�|dk	rj|t�}|dkrjP|j|�|�}q>W|S)Nr)�_timerZ)r%Z	predicaterY�resultZendtimeZwaittimerrr�wait_for7s		


zCondition.wait_for)r;r<r=r,r5r7r0r1r!rGrZr\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	Cs<|j�,|jjd�r-|jj�dSdSWdQRXdS)NFT)rarbr.r/)r%rrr�is_setSs


zEvent.is_setc	Cs?|j�/|jjd�|jj�|jj�WdQRXdS)NF)rarbr.r/r])r%rrr�setZs

z	Event.setc	Cs%|j�|jjd�WdQRXdS)NF)rarbr.)r%rrr�clear`s
zEvent.clearNc	Csn|j�^|jjd�r,|jj�n|jj|�|jjd�r_|jj�dSdSWdQRXdS)NFT)rarbr.r/rZ)r%rYrrrrZds

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�_staterP)	r%Zparties�actionrYr)rhrg�wrapperZcondrrrr,vs	zBarrier.__init__cCsC|\|_|_|_|_|_|jj�jd�|_dS)Nr*)�_parties�_action�_timeoutra�_wrapperZcreate_memoryview�cast�_array)r%r6rrrr7s$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%rrrrP�szBarrier._countcCs||jd<dS)Nr	)rr)r%r'rrrrP�s)
r;r<r=r,r7r5�propertyrj�setterrPrrrrrfts	rf)�__all__rNrr>rrr^�r
rrr
r�ImportError�listrrQr@rA�objectrrrrrrrfrrrr�<module>s0
Mz'

?>