a XC?h�.�@s�gd�ZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl Z ddl mZddl mZejjZddlmZmZmZmZmZGdd �d e�Ze�ZGd d �d e�ZGd d �d e�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�Zd0dd�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�Zdd �Zd!d"�Zd#d$�Zed%d&��Zed'd(��Zed)d*��Zed+d,��ZdS)1rrcCs�|dkrddlm}||_tjdd�\|_|_|��|_t � �|_ t j dkrTd|_n |��|_|�|�|_d|_|��t j dkr�t|tj�dS)Nrr)� SEM_VALUE_MAXF�Zduplex�win32)Z synchronizer�_maxsizer�Pipe�_reader�_writer�Lock�_rlock�os�getpid�_opid�sys�platform�_wlockZBoundedSemaphore�_sem� _ignore_epipe�_resetr r� _after_fork��self�maxsize�ctx�r&�;/opt/alt/python39/lib64/python3.9/multiprocessing/queues.py�__init__%s       zQueue.__init__cCs.t�|�|j|j|j|j|j|j|j|j fS�N) r �assert_spawningrrrrrrrr�r#r&r&r'� __getstate__9s �zQueue.__getstate__c Cs0|\|_|_|_|_|_|_|_|_|��dSr)) rrrrrrrrr �r#�stater&r&r'� __setstate__>s�zQueue.__setstate__cCstd�|jdd�dS)NzQueue._after_fork()T)� after_fork)r r r+r&r&r'r!CszQueue._after_forkFcCsj|r|j��nt�t���|_t��|_d|_d|_ d|_ d|_ d|_ |j j|_|jj|_|jj|_dS�NF)� _notempty�_at_fork_reinit� threading� Conditionr� collections�deque�_buffer�_thread� _jointhread�_joincancelled�_closed�_closer� send_bytes� _send_bytesr� recv_bytes� _recv_bytes�poll�_poll)r#r0r&r&r'r Gs    z Queue._resetTNcCsz|jrtd|�d���|j�||�s(t�|j�8|jdurB|��|j� |�|j� �Wd�n1sl0YdS�NzQueue z is closed) r<� ValueErrorr�acquirerr2r9� _start_threadr8�append�notify�r#�obj�block�timeoutr&r&r'�putVs  z Queue.putcCs�|jrtd|�d���|r\|dur\|j�|��}Wd�n1sF0Y|j��n||rlt��|}|j�||�s~t �zL|r�|t��}|� |�s�t �n |� �s�t �|��}|j��W|j��n |j��0t � |�SrD) r<rErrAr�release�time� monotonicrFrrC�_ForkingPickler�loads)r#rLrM�resZdeadliner&r&r'�getbs* &     z Queue.getcCs|j|jj��Sr))rr�_semlockZ _get_valuer+r&r&r'�qsize|sz Queue.qsizecCs |�� Sr)�rCr+r&r&r'�empty�sz Queue.emptycCs |jj��Sr))rrV�_is_zeror+r&r&r'�full�sz Queue.fullcCs |�d�Sr1)rUr+r&r&r'� get_nowait�szQueue.get_nowaitcCs |�|d�Sr1)rN�r#rKr&r&r'� put_nowait�szQueue.put_nowaitcCs d|_|j}|rd|_|�dS)NT)r<r=)r#�closer&r&r'r_�s z Queue.closecCstd�|jr|��dS)NzQueue.join_thread())r r:r+r&r&r'� join_thread�szQueue.join_threadcCs4td�d|_z|j��Wnty.Yn0dS)NzQueue.cancel_join_thread()T)r r;r:Zcancel�AttributeErrorr+r&r&r'�cancel_join_thread�s  zQueue.cancel_join_threadc Cs�td�|j��tjtj|j|j|j|j |j j |j j |j |j|jf dd�|_d|j_td�|j��td�|js�t|jtjt�|j�gdd�|_t|tj|j|jgd d�|_dS) NzQueue._start_thread()ZQueueFeederThread)�target�args�nameTzdoing self._thread.start()z... done self._thread.start()�����)Z exitpriority� )r r8�clearr4ZThreadr�_feedr2r?rrr_rr�_on_queue_feeder_errorrr9Zdaemon�startr;r �_finalize_join�weakref�refr:�_finalize_closer=r+r&r&r'rG�s4  ��  � �zQueue._start_threadcCs4td�|�}|dur(|��td�ntd�dS)Nzjoining queue threadz... queue thread joinedz... queue thread already dead)r �join)Ztwr�threadr&r&r'rl�s  zQueue._finalize_joincCsBtd�|�"|�t�|��Wd�n1s40YdS)Nztelling queue thread to quit)r rH� _sentinelrI)�buffer�notemptyr&r&r'ro�s zQueue._finalize_closec  Csrtd�|j} |j} |j} |j} t} tjdkr<|j}|j}nd}z�| �z|sT| �W| �n| �0zn| �}|| ur�td�|�|�WWdSt� |�}|dur�||�qh|�z||�W|�qh|�0qhWnt y�Yn0Wq@t �yj}zf|�r$t |dd�t jk�r$WYd}~dSt��rDtd|�WYd}~dS|��|||�WYd}~q@d}~00q@dS)Nz$starting thread to feed data to piperz%feeder thread got sentinel -- exiting�errnorzerror in queue thread: %s)r rFrO�wait�popleftrrrrrR�dumps� IndexError� Exception�getattrruZEPIPErr )rsrtr>Z writelockZ reader_closeZ writer_closeZ ignore_epipe�onerrorZ queue_semZnacquireZnreleaseZnwaitZbpopleft�sentinelZwacquireZwreleaserK�er&r&r'ri�sP       z Queue._feedcCsddl}|��dS)z� Private API hook called when feeding data in the background thread raises an exception. For overriding by concurrent.futures. rN)� traceback� print_exc)r~rKrr&r&r'rjszQueue._on_queue_feeder_error)r)F)TN)TN)�__name__� __module__� __qualname__r(r,r/r!r rNrUrWrYr[r\r^r_r`rbrG� staticmethodrlrorirjr&r&r&r'r#s0   !   >rc@s@eZdZddd�Zdd�Zdd�Zdd d �Zd d �Zdd�Zd S)rrcCs*tj|||d�|�d�|_|��|_dS)N)r%r)rr(Z Semaphore�_unfinished_tasksr5�_condr"r&r&r'r((s zJoinableQueue.__init__cCst�|�|j|jfSr))rr,r�r�r+r&r&r'r,-szJoinableQueue.__getstate__cCs,t�||dd��|dd�\|_|_dS)N�����)rr/r�r�r-r&r&r'r/0szJoinableQueue.__setstate__TNc Cs�|jrtd|�d���|j�||�s(t�|j�h|j�B|jdurJ|��|j � |�|j � �|j� �Wd�n1s~0YWd�n1s�0YdSrD)r<rErrFrr2r�r9rGr8rHr�rOrIrJr&r&r'rN4s   zJoinableQueue.putcCsT|j�:|j�d�std��|jj��r2|j��Wd�n1sF0YdS)NFz!task_done() called too many times)r�r�rFrErVrZZ notify_allr+r&r&r'� task_doneAs   zJoinableQueue.task_donecCs@|j�&|jj��s|j��Wd�n1s20YdSr))r�r�rVrZrvr+r&r&r'rpHs zJoinableQueue.join)r)TN) r�r�r�r(r,r/rNr�rpr&r&r&r'r&s   rc@sNeZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z e e j �Z dS)rcCsHtjdd�\|_|_|��|_|jj|_tj dkr:d|_ n |��|_ dS)NFrr) rrrrrrrBrCrrr)r#r%r&r&r'r(Ss    zSimpleQueue.__init__cCs|j��|j��dSr))rr_rr+r&r&r'r_\s zSimpleQueue.closecCs |�� Sr)rXr+r&r&r'rY`szSimpleQueue.emptycCst�|�|j|j|j|jfSr))r r*rrrrr+r&r&r'r,cs zSimpleQueue.__getstate__cCs"|\|_|_|_|_|jj|_dSr))rrrrrBrCr-r&r&r'r/gszSimpleQueue.__setstate__cCs:|j�|j��}Wd�n1s&0Yt�|�Sr))rrr@rRrS)r#rTr&r&r'rUks(zSimpleQueue.getcCsXt�|�}|jdur"|j�|�n2|j�|j�|�Wd�n1sJ0YdSr))rRrxrrr>r]r&r&r'rNqs   zSimpleQueue.putN)r�r�r�r(r_rYr,r/rUrN� classmethod�types� GenericAlias�__class_getitem__r&r&r&r'rQs  r)�__all__rrr4r6rPr�rmruZqueuerrZ_multiprocessing�rr Z reductionZForkingPicklerrR�utilr r r r r�objectrrrrrr&r&r&r'� s&  z +