e4:SrSSKrSSKrSSKJr SSKJrJr SSKJ r SSK J r /SQr SSK Jr "S S \5r"S S\5r"SS5r"SS\5r"SS\5r"SS5r\ c\r gg!\ a Sr N\f=f!\ a "S S \5rNhf=f)z'A multi-producer, multi-consumer queue.N)deque)heappushheappop) monotonic) SimpleQueue)EmptyFullShutDownQueue PriorityQueue LifoQueuer)rc\rSrSrSrSrg)rz4Exception raised by Queue.get(block=0)/get_nowait().N__name__ __module__ __qualname____firstlineno____doc____static_attributes__r+/opt/imh/python3.13/lib/python3.13/queue.pyrrs> rrc\rSrSrSrSrg)r z4Exception raised by Queue.put(block=0)/put_nowait().rNrrrrr r s:rr c\rSrSrSrSrg)r $z)Raised when put/get with shut-down queue.rNrrrrr r $s3rr c\rSrSrSrSSjrSrSrSrSr Sr SS jr SS jr S r S rSSjrSrSrSrSr\"\R,5rSrg )r (zbCreate a queue object with a given maximum size. If maxsize is <= 0, the queue size is infinite. c`XlURU5 [R"5Ul[R "UR5Ul[R "UR5Ul[R "UR5UlSUl SUl g)NrF) maxsize_init threadingLockmutex Condition not_emptynot_fullall_tasks_doneunfinished_tasks is_shutdownselfr!s r__init__Queue.__init__.s~  7 ^^% #,,TZZ8"++DJJ7 (11$**= !!rcUR URS- nUS::a+US:a [S5eURR5 XlSSS5 g!,(df  g=f)a8Indicate 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). shutdown(immediate=True) calls task_done() for each remaining item in the queue. Raises a ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesN)r)r* ValueError notify_all)r- unfinisheds r task_doneQueue.task_doneHs[" ..2JQ>$%HII##..0$. ! ! s AA A+cUR UR(a-URR5 UR(aM-SSS5 g!,(df  g=f)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)r)r*waitr-s rjoin Queue.joinasB ''##((*'''! s =A A#cpUR UR5sSSS5 $!,(df  g=f)9Return the approximate size of the queue (not reliable!).Nr%_qsizer9s rqsize Queue.qsizens ZZ;;=ZZs' 5czUR UR5(+sSSS5 $!,(df  g=f)aReturn 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>r9s rempty Queue.emptyss!ZZ{{}$ZZs, :cUR SURs=:=(a UR5:*Os sSSS5 $!,(df  g=f)a'Return 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)r%r!r?r9s rfull Queue.fulls/ZZt||44t{{}4ZZs -A ANcUR UR(a[eURS:GaGU(d&UR 5UR:a[ eGOUcpUR 5UR:aQURR 5 UR(a[eUR 5UR:aMQOUS:a [S5e[5U-nUR 5UR:akU[5- nUS::a[ eURR U5 UR(a[eUR 5UR:aMkURU5 U=RS- sl URR5 SSS5 g!,(df  g=f)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). Raises ShutDown if the queue has been shut down. rN''timeout' must be a non-negative numberr1) r(r+r r!r?r r8r2time_putr*r'notify)r-itemblocktimeoutendtime remainings rput Queue.putsF]]||a{{} 4" 5_++-4<<7 **,++"*N++-4<<7q[$%NOO"fw.G++-4<<7$+df$4 $+"&J **95++"*N ++-4<<7 IIdO  ! !Q & ! NN ! ! #3]]sCGB&G=AG GcUR UR(aUR5(d[eU(dUR5(d[eGO UcsUR5(d]URR 5 UR(aUR5(d[eUR5(dM]OUS:a [ S5e[5U-nUR5(dwU[5- nUS::a[eURR U5 UR(aUR5(d[eUR5(dMwUR5nURR5 UsSSS5 $!,(df  g=f)a6Remove 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). Raises ShutDown if the queue has been shut down and is empty, or if the queue has been shut down immediately. NrrIrJ) r'r+r?r rr8r2rK_getr(rM)r-rOrPrQrRrNs rget Queue.gets'^^ {{}}K%++--NN'')'' &++--1 !JKK&7*++-- '$& 0I C'# NN'' 2'' & ++--99;D MM "1^^sCF3B)F3>+F33 Gc"URUSS9$)zPut an item into the queue without blocking. Only enqueue the item if a free slot is immediately available. Otherwise raise the Full exception. FrOrSr-rNs r put_nowaitQueue.put_nowait xxEx**rc URSS9$zRemove and return an item from the queue without blocking. Only get an item if one is immediately available. Otherwise raise the Empty exception. FrZrWr9s r get_nowaitQueue.get_nowait xxex$$rcUR SUlU(a{UR5(aLUR5 URS:aU=RS-slUR5(aMLUR R 5 URR 5 URR 5 SSS5 g!,(df  g=f)ajShut-down the queue, making queue gets and puts raise ShutDown. By default, gets will only raise once the queue is empty. Set 'immediate' to True to make gets raise immediately instead. All blocked callers of put() and get() will be unblocked. If 'immediate', a task is marked as done for each item remaining in the queue, which may unblock callers of join(). Trr1N) r%r+r?rVr*r)r3r'r()r- immediates rshutdownQueue.shutdownsZZ#D kkmmIIK,,q0--2-kkmm ##..0 NN % % ' MM $ $ &ZZsA.C=AC C"c"[5UlgN)rqueuer,s rr" Queue._inits W rc,[UR5$rklenrlr9s rr? Queue._qsize 4::rc:URRU5 grkrlappendr\s rrL Queue._put $rc6URR5$rk)rlpopleftr9s rrV Queue._getszz!!##r)r)r+r!r%r'r(rlr*)rTN)F)rrrrrr.r5r:r@rCrFrSrWr]rcrhr"r?rLrV classmethodtypes GenericAlias__class_getitem__rrrrr r (sg !4/2 +! % 5&$P&P+%'8 $$E$6$67rr c0\rSrSrSrSrSrSrSrSr g) r izVariant of Queue that retrieves open entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). c/Ulgrkrlr,s rr"PriorityQueue._init  rc,[UR5$rkror9s rr?PriorityQueue._qsize"rrrc0[URU5 grk)rrlr\s rrLPriorityQueue._put%sT"rc,[UR5$rk)rrlr9s rrVPriorityQueue._get(stzz""rrN rrrrrr"r?rLrVrrrrr r s ##rr c0\rSrSrSrSrSrSrSrSr g) r i,zBVariant of Queue that retrieves most recently added entries first.c/Ulgrkrr,s rr"LifoQueue._init/rrc,[UR5$rkror9s rr?LifoQueue._qsize2rrrc:URRU5 grkrtr\s rrLLifoQueue._put5rwrc6URR5$rk)rlpopr9s rrVLifoQueue._get8szz~~rrNrrrrr r ,sL  rr cn\rSrSrSrSrS SjrS SjrSrSr S r S r \ "\ R5rS rg) _PySimpleQueuei<zQSimple, unbounded FIFO queue. This pure Python implementation is not reentrant. cX[5Ul[R"S5Ulg)Nr)r_queuer# Semaphore_countr9s rr._PySimpleQueue.__init__Fsg ))!, rNcnURRU5 URR5 g)zPut 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)rrurrelease)r-rNrOrPs rrS_PySimpleQueue.putJs& 4  rcUbUS:a [S5eURRX5(d[eURR 5$)aRemove 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). rrI)r2racquirerrry)r-rOrPs rrW_PySimpleQueue.getSsI  7Q;FG G{{""522K{{""$$rc"URUSS9$)zPut 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. FrZr[r\s rr]_PySimpleQueue.put_nowaitdr_rc URSS9$rarbr9s rrc_PySimpleQueue.get_nowaitlrerc2[UR5S:H$)zCReturn True if the queue is empty, False otherwise (not reliable!).rrprr9s rrC_PySimpleQueue.emptyts4;;1$$rc,[UR5$)r=rr9s rr@_PySimpleQueue.qsizexs4;;r)rrr{)rrrrrr.rSrWr]rcrCr@r|r}r~rrrrrrr<s=-%"+%% $E$6$67rr)rr#r} collectionsrheapqrrrKrrr ImportError__all__r Exceptionr r r r r rrrrrs- #""    9 4y4n8n8b#E#&    @8@8F Kk K     s"A8B8BBBB