Your IP : 3.12.153.240


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

�
e f%-�@s,dddgZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlZddlm
Z
ddlmZdd	lmZmZmZmZmZdd
lmZGdd�de�Ze�ZGdd�de�ZGd
d�de�ZdS)�Queue�SimpleQueue�
JoinableQueue�N)�Empty�Full�)�
connection)�context)�debug�info�Finalize�register_after_fork�
is_exiting)�ForkingPicklerc@s	eZdZddd�Zdd�Zdd�Zdd	�Zd
ddd
�Zd
ddd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zed"d#��Zed$d%��Zed&d'��ZdS)(rrcCs�|dkrddlm}n||_tjdd�\|_|_|j�|_t	j
�|_tj
dkrd|_n|j�|_|j|�|_d|_|j�tj
dkr�t|tj�ndS)Nrr)�
SEM_VALUE_MAX�duplexF�win32)Zsynchronizer�_maxsizer�Pipe�_reader�_writer�Lock�_rlock�os�getpid�_opid�sys�platform�_wlockZBoundedSemaphore�_sem�
_ignore_epipe�_after_forkr
r)�self�maxsize�ctx�r%�;/opt/alt/python34/lib64/python3.4/multiprocessing/queues.py�__init__$s		
zQueue.__init__cCsAtj|�|j|j|j|j|j|j|j|j	fS)N)
r	�assert_spawningr rrrrrrr)r"r%r%r&�__getstate__9s
zQueue.__getstate__c	CsD|\|_|_|_|_|_|_|_|_|j�dS)N)	r rrrrrrrr!)r"�stater%r%r&�__setstate__>s6zQueue.__setstate__cCs�td�tjtj��|_tj�|_d|_d|_	d|_
d|_d|_|j
j|_|jj|_|jj|_dS)NzQueue._after_fork()F)r
�	threading�	Conditionr�	_notempty�collections�deque�_buffer�_thread�_jointhread�_joincancelled�_closed�_closer�
send_bytes�_send_bytesr�
recv_bytes�_recv_bytes�poll�_poll)r"r%r%r&r!Cs
					zQueue._after_forkTNc
Cs�|jst�|jj||�s.t�n|jj�z=|jdkrZ|j�n|jj	|�|jj
�Wd|jj�XdS)N)r5�AssertionErrorr�acquirerr.r2�
_start_threadr1�append�notify�release)r"�obj�block�timeoutr%r%r&�putPs	

z	Queue.putc
Cs|r>|dkr>|j�|j�}WdQX|jj�n�|rWtj�|}n|jj||�sut�nzp|r�|tj�}|dks�|j|�r�t�q�n|j�s�t�n|j�}|jj�Wd|jj�Xtj	|�S)Nr)
rr:rrB�timer>rr<r�loads)r"rDrE�resZdeadliner%r%r&�get^s&
		z	Queue.getcCs|j|jjj�S)N)rr�_semlockZ
_get_value)r"r%r%r&�qsizevszQueue.qsizecCs|j�S)N)r<)r"r%r%r&�emptyzszQueue.emptycCs|jjj�S)N)rrK�_is_zero)r"r%r%r&�full}sz
Queue.fullcCs
|jd�S)NF)rJ)r"r%r%r&�
get_nowait�szQueue.get_nowaitcCs|j|d�S)NF)rF)r"rCr%r%r&�
put_nowait�szQueue.put_nowaitcCsDd|_z|jj�Wd|j}|r?d|_|�nXdS)NT)r5r�closer6)r"rRr%r%r&rR�s			zQueue.closecCs3td�|jst�|jr/|j�ndS)NzQueue.join_thread())r
r5r=r3)r"r%r%r&�join_thread�s
	zQueue.join_threadcCs=td�d|_y|jj�Wntk
r8YnXdS)NzQueue.cancel_join_thread()T)r
r4r3Zcancel�AttributeError)r"r%r%r&�cancel_join_thread�s
	
zQueue.cancel_join_threadc
Cstd�|jj�tjdtjd|j|j|j|j	|j
j|jfdd�|_
d|j
_td�|j
j�td�|jtj�k}|jr�|r�t|j
tjtj|j
�gd	d�|_nt|tj|j|jgd	d�|_dS)
NzQueue._start_thread()�target�args�nameZQueueFeederThreadTzdoing self._thread.start()z... done self._thread.start()Zexitpriority��
���)r
r1�clearr,ZThreadr�_feedr.r8rrrRr r2Zdaemon�startrrrr4r�_finalize_join�weakref�refr3�_finalize_closer6)r"Zcreated_by_this_processr%r%r&r?�s*

		


	zQueue._start_threadcCsDtd�|�}|dk	r6|j�td�n
td�dS)Nzjoining queue threadz... queue thread joinedz... queue thread already dead)r
�join)ZtwrZthreadr%r%r&r_�s
	

zQueue._finalize_joinc
CsAtd�|j�z|jt�|j�Wd|j�XdS)Nztelling queue thread to quit)r
r>r@�	_sentinelrArB)�buffer�notemptyr%r%r&rb�s


zQueue._finalize_closecCs�td�|j}|j}|j}|j}	t}
tjdkrX|j}|j}nd}y�x�|�z|s~|�nWd|�Xy}xv|	�}
|
|
kr�td�|�dStj	|
�}
|dkr�||
�q�|�z||
�Wd|�Xq�WWqdt
k
rYqdXqdWWn�tk
r�}zr|r[t|dd�t
jkr[dSy3t�rwtd|�nddl}|j�Wntk
r�YnXWYdd}~XnXdS)Nz$starting thread to feed data to piperz%feeder thread got sentinel -- exiting�errnorzerror in queue thread: %s)r
r>rB�wait�popleftrdrrr�dumps�
IndexError�	Exception�getattrrgZEPIPErr�	traceback�	print_exc)rerfr7Z	writelockrRZignore_epipeZnacquireZnreleaseZnwaitZbpopleft�sentinelZwacquireZwreleaserC�ernr%r%r&r]�sV
						



!	
zQueue._feed)�__name__�
__module__�__qualname__r'r)r+r!rFrJrLrMrOrPrQrRrSrUr?�staticmethodr_rbr]r%r%r%r&r"s$

&

c@saeZdZddd�Zdd�Zdd�Zdd	d
d�Zdd
�Zdd�Zd	S)rrcCs;tj||d|�|jd�|_|j�|_dS)Nr$r)rr'Z	Semaphore�_unfinished_tasksr-�_cond)r"r#r$r%r%r&r'szJoinableQueue.__init__cCstj|�|j|jfS)N)rr)rwrv)r"r%r%r&r)#szJoinableQueue.__getstate__cCs:tj||dd��|dd�\|_|_dS)N����ry)rr+rwrv)r"r*r%r%r&r+&szJoinableQueue.__setstate__TNc
Cs�|jst�|jj||�s.t�n|jj�|jj�zJ|jdkrg|j�n|j	j
|�|jj�|jj
�Wd|jj�|jj�XdS)N)r5r=rr>rr.rwr2r?r1r@rvrBrA)r"rCrDrEr%r%r&rF*s	




zJoinableQueue.putc
Csi|jj�zG|jjd�s1td��n|jjj�rS|jj�nWd|jj�XdS)NFz!task_done() called too many times)rwr>rv�
ValueErrorrKrNZ
notify_allrB)r"r%r%r&�	task_done;s
zJoinableQueue.task_donec
CsH|jj�z&|jjj�s2|jj�nWd|jj�XdS)N)rwr>rvrKrNrhrB)r"r%r%r&rcEs

zJoinableQueue.join)	rrrsrtr'r)r+rFr{rcr%r%r%r&rs
c@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rcCsjtjdd�\|_|_|j�|_|jj|_tj	dkrWd|_
n|j�|_
dS)NrFr)rrrrrrr;r<rrr)r"r$r%r%r&r'SszSimpleQueue.__init__cCs|j�S)N)r<)r"r%r%r&rM\szSimpleQueue.emptycCs)tj|�|j|j|j|jfS)N)r	r(rrrr)r"r%r%r&r)_s
zSimpleQueue.__getstate__cCs"|\|_|_|_|_dS)N)rrrr)r"r*r%r%r&r+cszSimpleQueue.__setstate__cCs,|j�|jj�}WdQXtj|�S)N)rrr9rrH)r"rIr%r%r&rJfs
zSimpleQueue.getc	CsUtj|�}|jdkr1|jj|�n |j�|jj|�WdQXdS)N)rrjrrr7)r"rCr%r%r&rFls

zSimpleQueue.putN)	rrrsrtr'rMr)r+rJrFr%r%r%r&rQs	)�__all__rrr,r/rGr`rgZqueuerrZ_multiprocessing�rr	�utilr
rrr
rZ	reductionr�objectrrdrrr%r%r%r&�<module>
s"(�	
5

?>