Your IP : 3.144.227.3


Current Path : /lib64/python3.6/multiprocessing/__pycache__/
Upload File :
Current File : //lib64/python3.6/multiprocessing/__pycache__/queues.cpython-36.pyc

3


 \*�@s�dddgZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlZddlm
Z
ddlmZejjZdd	lmZmZmZmZmZGd
d�de�Ze�ZGdd�de�ZGdd�de�ZdS)
�Queue�SimpleQueue�
JoinableQueue�N)�Empty�Full�)�
connection)�context)�debug�info�Finalize�register_after_fork�
is_exitingc@s�eZdZd(dd�Zdd�Zdd�Zdd	�Zd)dd
�Zd*dd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zed"d#��Zed$d%��Zed&d'��ZdS)+rrcCs�|dkrddlm}||_tjdd�\|_|_|j�|_t	j
�|_tj
dkrTd|_n
|j�|_|j|�|_d|_|j�tj
dkr�t|tj�dS)Nrr)�
SEM_VALUE_MAXF)�duplex�win32)Zsynchronizer�_maxsizer�Pipe�_reader�_writer�Lock�_rlock�os�getpid�_opid�sys�platform�_wlockZBoundedSemaphore�_sem�
_ignore_epipe�_after_forkr
r)�self�maxsize�ctx�r$�./usr/lib64/python3.6/multiprocessing/queues.py�__init__$s




zQueue.__init__cCs.tj|�|j|j|j|j|j|j|j|j	fS)N)
r	�assert_spawningrrrrrrrr)r!r$r$r%�__getstate__9s
zQueue.__getstate__c	Cs0|\|_|_|_|_|_|_|_|_|j�dS)N)	rrrrrrrrr )r!�stater$r$r%�__setstate__>s$zQueue.__setstate__cCsbtd�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st�|jj||�st�|j�.|jdkr8|j�|jj	|�|jj
�WdQRXdS)N)r4�AssertionErrorr�acquirerr-r1�
_start_threadr0�append�notify)r!�obj�block�timeoutr$r$r%�putPs
z	Queue.putc
Cs�|r2|dkr2|j�|j�}WdQRX|jj�nr|rBtj�|}|jj||�sTt�zB|rv|tj�}|j|�s�t�n|j�s�t�|j�}|jj�Wd|jj�Xt	j
|�S)N)rr9r�release�timeZ	monotonicr=rr;�_ForkingPickler�loads)r!rBrC�resZdeadliner$r$r%�get[s&
z	Queue.getcCs|j|jjj�S)N)rr�_semlockZ
_get_value)r!r$r$r%�qsizesszQueue.qsizecCs
|j�S)N)r;)r!r$r$r%�emptywszQueue.emptycCs|jjj�S)N)rrK�_is_zero)r!r$r$r%�fullzsz
Queue.fullcCs
|jd�S)NF)rJ)r!r$r$r%�
get_nowait}szQueue.get_nowaitcCs|j|d�S)NF)rD)r!rAr$r$r%�
put_nowait�szQueue.put_nowaitcCs2d|_z|jj�Wd|j}|r,d|_|�XdS)NT)r4r�closer5)r!rRr$r$r%rR�szQueue.closecCs$td�|jst�|jr |j�dS)NzQueue.join_thread())r
r4r<r2)r!r$r$r%�join_thread�s
zQueue.join_threadcCs6td�d|_y|jj�Wntk
r0YnXdS)NzQueue.cancel_join_thread()T)r
r3r2Zcancel�AttributeError)r!r$r$r%�cancel_join_thread�szQueue.cancel_join_threadcCs�td�|jj�tjtj|j|j|j|j	|j
j|jfdd�|_
d|j
_td�|j
j�td�|js�t|j
tjtj|j
�gd
d�|_t|tj|j|jgd	d�|_dS)NzQueue._start_thread()ZQueueFeederThread)�target�args�nameTzdoing self._thread.start()z... done self._thread.start()�)Zexitpriority�
���)r
r0�clearr+ZThreadr�_feedr-r7rrrRrr1Zdaemon�startr3r�_finalize_join�weakref�refr2�_finalize_closer5)r!r$r$r%r>�s(




zQueue._start_threadcCs4td�|�}|dk	r(|j�td�ntd�dS)Nzjoining queue threadz... queue thread joinedz... queue thread already dead)r
�join)ZtwrZthreadr$r$r%r_�s
zQueue._finalize_joinc	Cs.td�|�|jt�|j�WdQRXdS)Nztelling queue thread to quit)r
r?�	_sentinelr@)�buffer�notemptyr$r$r%rb�s
zQueue._finalize_closecCsPtd�|j}|j}|j}|j}	t}
tjdkr<|j}|j}nd}�xy�|�z|sX|�Wd|�Xybx\|	�}
|
|
kr�td�|�dStj	|
�}
|dkr�||
�qh|�z||
�Wd|�XqhWWnt
k
r�YnXWqDtk
�rF}zJ|�rt|dd�t
jk�rdSt��r&td|�dSddl}|j�WYdd}~XqDXqDWdS)Nz$starting thread to feed data to piperz%feeder thread got sentinel -- exiting�errnorzerror in queue thread: %s)r
r=rE�wait�popleftrdrrrG�dumps�
IndexError�	Exception�getattrrgZEPIPErr�	traceback�	print_exc)rerfr6Z	writelockrRZignore_epipeZnacquireZnreleaseZnwaitZbpopleft�sentinelZwacquireZwreleaserA�ernr$r$r%r]�sR





zQueue._feed)r)TN)TN)�__name__�
__module__�__qualname__r&r(r*r rDrJrLrMrOrPrQrRrSrUr>�staticmethodr_rbr]r$r$r$r%r"s$




c@s@eZdZddd�Zdd�Zdd�Zdd
d�Zdd
�Zdd�Zd	S)rrcCs*tj|||d�|jd�|_|j�|_dS)N)r#r)rr&Z	Semaphore�_unfinished_tasksr,�_cond)r!r"r#r$r$r%r&szJoinableQueue.__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__TNcCsx|jst�|jj||�st�|j�J|j�8|jdkr@|j�|j	j
|�|jj�|jj
�WdQRXWdQRXdS)N)r4r<rr=rr-rwr1r>r0r?rvrEr@)r!rArBrCr$r$r%rDs

zJoinableQueue.putc	Cs@|j�0|jjd�std��|jjj�r2|jj�WdQRXdS)NFz!task_done() called too many times)rwrvr=�
ValueErrorrKrNZ
notify_all)r!r$r$r%�	task_done's
zJoinableQueue.task_donec	Cs,|j�|jjj�s|jj�WdQRXdS)N)rwrvrKrNrh)r!r$r$r%rc.szJoinableQueue.join)r)TN)	rrrsrtr&r(r*rDr{rcr$r$r$r%r
s

c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rcCsHtjdd�\|_|_|j�|_|jj|_tj	dkr:d|_
n
|j�|_
dS)NF)rr)rrrrrrr:r;rrr)r!r#r$r$r%r&9s


zSimpleQueue.__init__cCs
|j�S)N)r;)r!r$r$r%rMBszSimpleQueue.emptycCstj|�|j|j|j|jfS)N)r	r'rrrr)r!r$r$r%r(Es
zSimpleQueue.__getstate__cCs"|\|_|_|_|_|jj|_dS)N)rrrrr:r;)r!r)r$r$r%r*IszSimpleQueue.__setstate__c	Cs&|j�|jj�}WdQRXtj|�S)N)rrr8rGrH)r!rIr$r$r%rJMszSimpleQueue.getc	CsDtj|�}|jdkr"|jj|�n|j�|jj|�WdQRXdS)N)rGrjrrr6)r!rAr$r$r%rDSs


zSimpleQueue.putN)	rrrsrtr&rMr(r*rJrDr$r$r$r%r7s	)�__all__rrr+r.rFr`rgZqueuerrZ_multiprocessing�rr	Z	reductionZForkingPicklerrG�utilr
rrr
r�objectrrdrrr$r$r$r%�<module>
s$
b
*

?>