§
»ºáä @ã óJ — d Z ddlZddlZddlmZ ddlmZmZ ddlm Z ddl
mZ n
# e$ r dZY nw xY wg d¢Z
ddl
mZ n# e$ r G d „ d
e¦ « ZY nw xY w G d„ de¦ « Z G d
„ d¦ « Z G d„ de¦ « Z G d„ de¦ « Z G d„ d¦ « Ze€eZdS dS )z'A multi-producer, multi-consumer queue.é N)Údeque)ÚheappushÚheappop)Ú monotonic)ÚSimpleQueue)ÚEmptyÚFullÚQueueÚ
PriorityQueueÚ LifoQueuer )r c ó — e Zd ZdZdS )r z4Exception raised by Queue.get(block=0)/get_nowait().N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó ú2/opt/alt/python-internal/lib64/python3.11/queue.pyr r s € € € € € Ø>Ð>؈r r c ó — e Zd ZdZdS )r z4Exception raised by Queue.put(block=0)/put_nowait().Nr r r r r r s € € € € € Ø:Ð:Ø€Dr r c óŒ — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z dd„Z
dd„Zd
„ Zd„ Z
d„ Zd„ Zd„ Zd„ Z eej ¦ « Zd
S )r
zjCreate a queue object with a given maximum size.
If maxsize is <= 0, the queue size is infinite.
r c ó0 — || _ | |¦ « t j ¦ « | _ t j | j ¦ « | _ t j | j ¦ « | _ t j | j ¦ « | _ d| _ d S ©Nr )
ÚmaxsizeÚ_initÚ threadingÚLockÚmutexÚ ConditionÚ not_emptyÚnot_fullÚall_tasks_doneÚunfinished_tasks©Úselfr s r Ú__init__zQueue.__init__" s} € ؈ŒØ�
Š
�7ÑÔÐõ ”^Ñ%Ô%ˆŒ
õ #Ô,¨T¬ZÑ8Ô8ˆŒõ "Ô+¨D¬JÑ7Ô7ˆŒ
õ (Ô1°$´*Ñ=Ô=ˆÔØ !ˆÔÐÐr c óÐ — | j 5 | j dz
}|dk r.|dk rt d¦ « ‚| j ¦ « || _ ddd¦ « dS # 1 swxY w Y dS )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.
é r z!task_done() called too many timesN)r" r# Ú
ValueErrorÚ
notify_all)r% Ú
unfinisheds r Ú task_donezQueue.task_done9 s¼ € ð Ô
ð /ð /ØÔ.°Ñ2ˆJؘQŠˆØ ’>�>Ý$Ð%HÑIÔIÐIØÔ#×.Ò.Ñ0Ô0Ð0Ø$.ˆDÔ!ð
/ð /ð /ñ /ô /ð /ð /ð /ð /ð /ð /ð /øøøð /ð /ð /ð /ð /ð /s ˆAAÁAÁ"Ac ó” — | j 5 | j r | j ¦ « | j ° ddd¦ « dS # 1 swxY w Y dS )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# Úwait©r% s r Újoinz
Queue.joinO sž € ð Ô
ð +ð +ØÔ'ð
+ØÔ#×(Ò(Ñ*Ô*Ð*ð Ô'ð
+ð +ð +ð +ñ +ô +ð +ð +ð +ð +ð +ð +ð +øøøð +ð +ð +ð +ð +ð +s ˆ(=½AÁAc ól — | j 5 | ¦ « cddd¦ « S # 1 swxY w Y dS )ú9Return the approximate size of the queue (not reliable!).N©r Ú_qsizer/ s r ÚqsizezQueue.qsize\ sy € à
ŒZð !ð !Ø—;’;‘=”=ð !ð !ð !ð !ñ !ô !ð !ð !ð !ð !ð !ð !øøøð !ð !ð !ð !ð !ð !s ˆ)©-°-c ón — | j 5 | ¦ « cddd¦ « S # 1 swxY w Y dS )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.
Nr3 r/ s r ÚemptyzQueue.emptya s~ € ð ŒZð %ð %Ø—{’{‘}”}Ð$ð %ð %ð %ð %ñ %ô %ð %ð %ð %ð %ð %ð %øøøð %ð %ð %ð %ð %ð %s ˆ*ª.±.c ó’ — | j 5 d| j cxk o| ¦ « k nc cddd¦ « S # 1 swxY w Y dS )aO 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.
r N)r r r4 r/ s r Úfullz
Queue.fullo s™ € ð ŒZð 5ð 5Ø�t”|Ð4Ð4Ò4Ð4 t§{¢{¡}¤}Ò4Ð4Ð4Ð4ð 5ð 5ð 5ð 5ñ 5ô 5ð 5ð 5ð 5ð 5ð 5ð 5øøøð 5ð 5ð 5ð 5ð 5ð 5s ˆ'<¼A ÁA TNc ó — | j 5 | j dk �r|s%| ¦ « | j k rt ‚nî|€T| ¦ « | j k r6| j ¦ « | ¦ « | j k °6n˜|dk rt d¦ « ‚t
¦ « |z }| ¦ « | j k rU|t
¦ « z
}|dk rt ‚| j |¦ « | ¦ « | j k °U| |¦ « | xj dz
c_ | j
¦ « ddd¦ « dS # 1 swxY w Y dS )a Put 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).
r Nú''timeout' must be a non-negative numberç r( )r! r r4 r r. r) ÚtimeÚ_putr# r Únotify)r% ÚitemÚblockÚtimeoutÚendtimeÚ remainings r Úputz Queue.putz s© € ð Œ]ð $ð $ØŒ|˜aÒÑØð 6Ø—{’{‘}”}¨¬Ò4Ð4Ý"˜
ð 5à�_ØŸ+š+™-œ-¨4¬<Ò7Ð7Øœ
×*Ò*Ñ,Ô,Ð,ð Ÿ+š+™-œ-¨4¬<Ò7Ð7øà˜q’[�[Ý$Ð%NÑOÔOÐOå"™fœf wÑ.�GØŸ+š+™-œ-¨4¬<Ò7Ð7Ø$+d©f¬fÑ$4˜ Ø$¨Ò+Ð+Ý"&˜JØœ
×*Ò*¨9Ñ5Ô5Ð5ð Ÿ+š+™-œ-¨4¬<Ò7Ð7ð
�IŠI�d‰OŒOˆOØÐ!Ô! QÑ&Ð!Ô!ØŒN×!Ò!Ñ#Ô#Ð#ð' $ð $ð $ñ $ô $ð $ð $ð $ð $ð $ð $ð $øøøð $ð $ð $ð $ð $ð $s ˆE E5Å5E9Å<E9c ór — | j 5 |s| ¦ « st ‚nÊ|€B| ¦ « s-| j ¦ « | ¦ « ¯-n†|dk rt d¦ « ‚t ¦ « |z }| ¦ « sL|t ¦ « z
}|dk rt ‚| j |¦ « | ¦ « ¯L| ¦ « }| j ¦ « |cddd¦ « S # 1 swxY w Y dS )á 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).
Nr r; r<