grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026U iÛf\,ã@sdZddlZddlmZddlmZmZddlmZzddl m Z Wne k r\dZ YnXddd d d d gZ zdd l m Z Wn$e k r¢Gdd„deƒZ YnXGdd„deƒZGdd „d ƒZGdd „d eƒZGdd „d eƒZGdd„dƒZe dkrüeZ dS)z'A multi-producer, multi-consumer queue.éN)Údeque)ÚheappushÚheappop)Ú monotonic)Ú SimpleQueueÚEmptyÚFullÚQueueÚ PriorityQueueÚ LifoQueuer)rc@seZdZdZdS)rz4Exception raised by Queue.get(block=0)/get_nowait().N©Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrú*/opt/alt/python38/lib64/python3.8/queue.pyrsc@seZdZdZdS)rz4Exception raised by Queue.put(block=0)/put_nowait().Nr rrrrrsc@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 „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__c CsH|j�8|jd}|dkr4|dkr*tdƒ‚|j ¡||_W5QRXdS)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_done8s  zQueue.task_donec Cs(|j�|jr|j ¡qW5QRXdS)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ÚjoinNs z Queue.joinc Cs&|j�| ¡W5QR£SQRXdS)ú9Return the approximate size of the queue (not reliable!).N©rÚ_qsizer#rrrÚqsize[sz Queue.qsizec Cs(|j�| ¡ W5QR£SQRXdS)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Úempty`s z Queue.emptyc Cs<|j�,d|jko | ¡knW5QR£SQRXdS)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Úfullnsz Queue.fullTNc CsÌ|j�¼|jdkrœ|s*| ¡|jkrœt‚nr|dkrN| ¡|jkrœ|j ¡q2nN|dkr`tdƒ‚nr#rrrr?/sz_PySimpleQueue.get_nowaitcCst|jƒdkS)zCReturn True if the queue is empty, False otherwise (not reliable!).r©rCrKr#rrrr)7sz_PySimpleQueue.emptycCs t|jƒS)r%rOr#rrrr(;sz_PySimpleQueue.qsize)TN)TN) r rrrrr5r8r<r?r)r(rrrrrJÿs  rJ)rrÚ collectionsrÚheapqrrr-rrKrÚ ImportErrorÚ__all__rÚ Exceptionrr r r rJrrrrÚs*   BA