grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026o ®û|jè,ã@sdZddlZddlZddlmZddlmZmZddlm Zzddl m Z Wn e y1dZ Ynwgd¢Z zddl mZWne yOGd d „d eƒZYnwGd d „d eƒZGd d„dƒZGdd„deƒZGdd„deƒZGdd„dƒZe dur~eZ dSdS)z'A multi-producer, multi-consumer queue.éN)Údeque)ÚheappushÚheappop)Ú monotonic)Ú SimpleQueue)ÚEmptyÚFullÚQueueÚ PriorityQueueÚ LifoQueuer)rc@óeZdZdZdS)rz4Exception raised by Queue.get(block=0)/get_nowait().N©Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrú,/opt/alt/python310/lib64/python3.10/queue.pyrórc@r )rz4Exception raised by Queue.put(block=0)/put_nowait().Nr rrrrrrrc@s�eZdZdZd!dd„Zdd„Zdd„Zd d „Zd d „Zd d„Z d"dd„Z d"dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd „ZeejƒZdS)#r zjCreate a queue object with a given maximum size. If maxsize is <= 0, the queue size is infinite. rcCsN||_| |¡t ¡|_t |j¡|_t |j¡|_t |j¡|_d|_ dS©Nr) ÚmaxsizeÚ_initÚ threadingZLockÚmutexZ ConditionÚ not_emptyÚnot_fullÚall_tasks_doneÚunfinished_tasks©ÚselfrrrrÚ__init__"s   zQueue.__init__cCs^|j�"|jd}|dkr|dkrtdƒ‚|j ¡||_WdƒdS1s(wYdS)a.Indicate that a formerly enqueued task is complete. Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises a ValueError if called more times than there were items placed in the queue. érz!task_done() called too many timesN)rrÚ ValueErrorZ notify_all)rZ unfinishedrrrÚ task_done9s  "úzQueue.task_donecCsR|j�|jr|j ¡|jsWdƒdSWdƒdS1s"wYdS)aƒBlocks until all items in the Queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls task_done() to indicate the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. N)rrÚwait©rrrrÚjoinOs  ÿÿ"ÿz Queue.joincCs2|j� | ¡WdƒS1swYdS)ú9Return the approximate size of the queue (not reliable!).N©rÚ_qsizer%rrrÚqsize\s$ÿz Queue.qsizecCs4|j� | ¡ WdƒS1swYdS)aÝReturn True if the queue is empty, False otherwise (not reliable!). This method is likely to be removed at some point. Use qsize() == 0 as a direct substitute, but be aware that either approach risks a race condition where a queue can grow before the result of empty() or qsize() can be used. To create code that needs to wait for all queued tasks to be completed, the preferred technique is to use the join() method. Nr(r%rrrÚemptyas $ÿz Queue.emptycCsH|j�d|jko| ¡knWdƒS1swYdS)aOReturn True if the queue is full, False otherwise (not reliable!). This method is likely to be removed at some point. Use qsize() >= n as a direct substitute, but be aware that either approach risks a race condition where a queue can shrink before the result of full() or qsize() can be used. rN)rrr)r%rrrÚfullos$ÿz Queue.fullTNcCsø|j�o|jdkrY|s| ¡|jkrt‚nD|dur-| ¡|jkr,|j ¡| ¡|jks n,|dkr5tdƒ‚tƒ|}| ¡|jkrY|tƒ}|dkrLt‚|j |¡| ¡|jksA| |¡|jd7_|j   ¡WdƒdS1suwYdS)aPut an item into the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until a free slot is available. If 'timeout' is a non-negative number, it blocks at most 'timeout' seconds and raises the Full exception if no free slot was available within that time. Otherwise ('block' is false), put an item on the queue if a free slot is immediately available, else raise the Full exception ('timeout' is ignored in that case). rNú''timeout' must be a non-negative numberçr!) rrr)rr$r"ÚtimeÚ_putrrÚnotify)rÚitemÚblockÚtimeoutÚendtimeÚ remainingrrrÚputzs0 ÿ ÿ€   ü  "íz Queue.putcCsÂ|j�T|s | ¡s t‚n8|dur| ¡s|j ¡| ¡rn&|dkr'tdƒ‚tƒ|}| ¡sE|tƒ}|dkr;t‚|j |¡| ¡r0| ¡}|j ¡|WdƒS1sZwYdS)áRemove and return an item from the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until an item is available. If 'timeout' is a non-negative number, it blocks at most 'timeout' seconds and raises the Empty exception if no item was available within that time. Otherwise ('block' is false), return an item if one is immediately available, else raise the Empty exception ('timeout' is ignored in that case). Nrr-r.) rr)rr$r"r/Ú_getrr1)rr3r4r5r6r2rrrÚgetšs. ÿ ÿ€   ü $îz Queue.getcCó|j|dd�S)z©Put an item into the queue without blocking. Only enqueue the item if a free slot is immediately available. Otherwise raise the Full exception. F©r3©r7©rr2rrrÚ put_nowait¹ózQueue.put_nowaitcCó |jdd�S©z«Remove and return an item from the queue without blocking. Only get an item if one is immediately available. Otherwise raise the Empty exception. Fr<©r:r%rrrÚ get_nowaitÁó zQueue.get_nowaitcCs tƒ|_dS©N)rÚqueuerrrrrÎs z Queue._initcCó t|jƒSrF©ÚlenrGr%rrrr)Ñó z Queue._qsizecCó|j |¡dSrF©rGÚappendr>rrrr0Õóz Queue._putcCó |j ¡SrF)rGÚpopleftr%rrrr9ÙrKz Queue._get)r©TN)rrrrr r#r&r*r+r,r7r:r?rDrr)r0r9Ú classmethodÚtypesÚ GenericAliasÚ__class_getitem__rrrrr s"    r c@ó0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) r zœVariant of Queue that retrieves open entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCó g|_dSrF©rGrrrrrårKzPriorityQueue._initcCrHrFrIr%rrrr)èrKzPriorityQueue._qsizecCst|j|ƒdSrF)rrGr>rrrr0ërOzPriorityQueue._putcCrHrF)rrGr%rrrr9îrKzPriorityQueue._getN©rrrrrr)r0r9rrrrr ßs  r c@rW) r zBVariant of Queue that retrieves most recently added entries first.cCrXrFrYrrrrrõrKzLifoQueue._initcCrHrFrIr%rrrr)ørKzLifoQueue._qsizecCrLrFrMr>rrrr0ûrOzLifoQueue._putcCrPrF)rGÚpopr%rrrr9þrKzLifoQueue._getNrZrrrrr òs  r c@sVeZdZdZdd„Zddd„Zddd „Zd d „Zd d „Zdd„Z dd„Z e e j ƒZdS)Ú_PySimpleQueuezYSimple, unbounded FIFO queue. This pure Python implementation is not reentrant. cCstƒ|_t d¡|_dSr)rÚ_queuerZ SemaphoreÚ_countr%rrrr sz_PySimpleQueue.__init__TNcCs|j |¡|j ¡dS)zÆPut the item on the queue. The optional 'block' and 'timeout' arguments are ignored, as this method never blocks. They are provided for compatibility with the Queue class. N)r]rNr^Úrelease)rr2r3r4rrrr7s z_PySimpleQueue.putcCs4|dur |dkr tdƒ‚|j ||¡st‚|j ¡S)r8Nrr-)r"r^Úacquirerr]rQ)rr3r4rrrr:s   z_PySimpleQueue.getcCr;)zºPut an item into the queue without blocking. This is exactly equivalent to `put(item, block=False)` and is only provided for compatibility with the Queue class. Fr<r=r>rrrr?*r@z_PySimpleQueue.put_nowaitcCrArBrCr%rrrrD2rEz_PySimpleQueue.get_nowaitcCst|jƒdkS)zCReturn True if the queue is empty, False otherwise (not reliable!).r©rJr]r%rrrr+:sz_PySimpleQueue.emptycCrH)r'rar%rrrr*>s z_PySimpleQueue.qsizerR)rrrrr r7r:r?rDr+r*rSrTrUrVrrrrr\s  r\)rrrTÚ collectionsrÚheapqrrr/rr]rÚ ImportErrorÚ__all__rÚ Exceptionrr r r r\rrrrÚs4   ÿ ÿDCÿ