zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
U
¸ý°d!)ã@s6dZddlmZddlZddlmZddlZddlmZddl    Z    ddl    m
Z
ddl    m Z ddl    m Z dd    l    m Z dd
l    mZdd l    mZd d lmZd dlmZd dlmZede
dZdddgZGdd„deƒZGdd„deƒZGdd„de eƒZGdd„deeƒZGdd„deeƒZGdd„deeƒZdS)aðAn adaptation of Py2.3/2.4's Queue module which supports reentrant
behavior, using RLock instead of Lock for its mutex object.  The
Queue object is used exclusively by the sqlalchemy.pool.QueuePool
class.
 
This is to support the connection pool's usage of weakref callbacks to return
connections to the underlying Queue, which can in extremely
rare cases be invoked within the ``get()`` method of the Queue itself,
producing a ``put()`` inside the ``get()`` and therefore a reentrant
condition.
 
é)Ú annotationsN)Údeque)Útime)ÚAny)Ú    Awaitable)ÚDeque)ÚGeneric)ÚOptional)ÚTypeVaré)Úawait_fallback)Ú
await_only)Úmemoized_propertyÚ_T)ÚboundÚEmptyÚFullÚQueuec@seZdZdZdS)rz4Exception raised by Queue.get(block=0)/get_nowait().N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__©rrúLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/util/queue.pyr,sc@seZdZdZdS)rz4Exception raised by Queue.put(block=0)/put_nowait().Nrrrrrr2sc@s¢eZdZUded<ded<d!dddœdd    „Zdd
œd d „Zdd
œd d„Zdd
œdd„Zdddœdd„Zd"dddddœdd„Z    dd
œdd„Z
d#ddddœdd „Z dS)$Ú QueueCommonÚintÚmaxsizeÚboolÚuse_liforF©rrcCsdS©Nr©ÚselfrrrrrÚ__init__<szQueueCommon.__init__©ÚreturncCs
tƒ‚dSr!©ÚNotImplementedError©r#rrrÚempty?szQueueCommon.emptycCs
tƒ‚dSr!r'r)rrrÚfullBszQueueCommon.fullcCs
tƒ‚dSr!r'r)rrrÚqsizeEszQueueCommon.qsizerÚNone©Úitemr&cCs
tƒ‚dSr!r'©r#r/rrrÚ
put_nowaitHszQueueCommon.put_nowaitTNúOptional[float]©r/ÚblockÚtimeoutr&cCs
tƒ‚dSr!r')r#r/r4r5rrrÚputKszQueueCommon.putcCs
tƒ‚dSr!r'r)rrrÚ
get_nowaitPszQueueCommon.get_nowait©r4r5r&cCs
tƒ‚dSr!r')r#r4r5rrrÚgetSszQueueCommon.get)rF)TN)TN) rrrÚ__annotations__r$r*r+r,r1r6r7r9rrrrr8s
ÿrc@sòeZdZUded<d.dddœdd    „Zdd
œd d „Zdd
œd d„Zdd
œdd„Zd/dddddœdd„Zdddœdd„Z    d0ddddœdd„Z
dd
œdd „Z ddd!œd"d#„Z dd
œd$d%„Z dd
œd&d'„Zdd
œd(d)„Zdddœd*d+„Zdd
œd,d-„ZdS)1rz    Deque[_T]ÚqueuerFrrr cCs:| |¡t ¡|_t |j¡|_t |j¡|_||_dS)z½Initialize a queue object with a given maximum size.
 
        If `maxsize` is <= 0, the queue size is infinite.
 
        If `use_lifo` is True, this Queue acts like a Stack (LIFO).
        N)Ú_initÚ    threadingÚRLockÚmutexÚ    ConditionÚ    not_emptyÚnot_fullrr"rrrr$Zs
 
 
zQueue.__init__r%c
Cs&|j| ¡W5QR£SQRXdS)z9Return the approximate size of the queue (not reliable!).N)r?Ú_qsizer)rrrr,qsz Queue.qsizec
Cs&|j| ¡W5QR£SQRXdS)zKReturn True if the queue is empty, False otherwise (not
        reliable!).N)r?Ú_emptyr)rrrr*wsz Queue.emptyc
Cs&|j| ¡W5QR£SQRXdS)zJReturn True if the queue is full, False otherwise (not
        reliable!).N)r?Ú_fullr)rrrr+~sz
Queue.fullTNrr2r-r3c    Cs |j|s| ¡r~t‚nd|dkr8| ¡r~|j ¡q"nF|dkrHtdƒ‚tƒ|}| ¡r~|tƒ}|dkrpt‚|j |¡qR| |¡|j ¡W5QRXdS)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 positive 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).
        Nrú#'timeout' must be a positive numberç)    rBrErÚwaitÚ
ValueErrorÚ_timeÚ_putrAÚnotify)r#r/r4r5ÚendtimeÚ    remainingrrrr6…s"
 
 
z    Queue.putr.cCs | |d¡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)r6r0rrrr1§szQueue.put_nowaitr8c
Csª|jš|s| ¡r~t‚nd|dkr8| ¡r~|j ¡q"nF|dkrHtdƒ‚tƒ|}| ¡r~|tƒ}|dkrpt‚|j |¡qR| ¡}|j ¡|W5QR£SQRXdS)a 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 positive 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).
 
        NrrFrG)    rArDrrHrIrJÚ_getrBrL)r#r4r5rMrNr/rrrr9¯s$ 
 
 
z    Queue.getcCs
| d¡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.
        F)r9r)rrrr7ÏszQueue.get_nowait)rr&cCs||_tƒ|_dSr!)rrr;)r#rrrrr<Øsz Queue._initcCs
t|jƒSr!)Úlenr;r)rrrrCÜsz Queue._qsizecCs|j Sr!)r;r)rrrrDßsz Queue._emptycCs|jdkot|jƒ|jkS)Nr)rrPr;r)rrrrEâsz Queue._fullcCs|j |¡dSr!)r;Úappendr0rrrrKåsz
Queue._putcCs|jr|j ¡S|j ¡SdSr!)rr;ÚpopÚpopleftr)rrrrOès
z
Queue._get)rF)TN)TN)rrrr:r$r,r*r+r6r1r9r7r<rCrDrErKrOrrrrrWs"
ÿ"     c@sºeZdZejr$edddœdd„ƒZneeƒZd&dd    d
œd d „Zd    d œdd„Z    dd„Z
dd„Z e dd œdd„ƒZ dddœdd„Zd'dd    dddœdd „Zdd œd!d"„Zd(d    ddd#œd$d%„ZdS))ÚAsyncAdaptedQueuezAwaitable[Any]r)Ú    coroutiner&cCsdSr!r)rUrrrÚawait_ôszAsyncAdaptedQueue.await_rFrrr cCs||_||_dSr!)rrr"rrrr$ûszAsyncAdaptedQueue.__init__r%cCs
|j ¡Sr!)Ú_queuer*r)rrrr*ÿszAsyncAdaptedQueue.emptycCs
|j ¡Sr!)rWr+r)rrrr+szAsyncAdaptedQueue.fullcCs
|j ¡Sr!)rWr,r)rrrr,szAsyncAdaptedQueue.qsizezasyncio.Queue[_T]cCs(|jrtj|jd}ntj|jd}|S)N)r)rÚasyncioÚ    LifoQueuerr)r#r;rrrrWs zAsyncAdaptedQueue._queuer-r.c
CsBz|j |¡Wn,tjk
r<}z tƒ|‚W5d}~XYnXdSr!)rWr1rXÚ    QueueFullr)r#r/Úerrrrrr1szAsyncAdaptedQueue.put_nowaitTNr2r3c
Cs€|s| |¡Sz:|dk    r4| t |j |¡|¡¡n| |j |¡¡Wn2tjtjfk
rz}z tƒ|‚W5d}~XYnXdSr!)    r1rVrXÚwait_forrWr6rZÚ TimeoutErrorr)r#r/r4r5r[rrrr6s
zAsyncAdaptedQueue.putc
Cs>z |j ¡WStjk
r8}z tƒ|‚W5d}~XYnXdSr!)rWr7rXÚ
QueueEmptyr)r#r[rrrr7-s zAsyncAdaptedQueue.get_nowaitr8c
Cs||s | ¡Sz8|dk    r0| t |j ¡|¡¡WS| |j ¡¡WSWn2tjtjfk
rv}z tƒ|‚W5d}~XYnXdSr!)    r7rVrXr\rWr9r^r]r)r#r4r5r[rrrr93sÿzAsyncAdaptedQueue.get)rF)TN)TN)rrrÚtypingÚ TYPE_CHECKINGÚ staticmethodrVr r$r*r+r,rrWr1r6r7r9rrrrrTñs ÿrTc@seZdZejseeƒZdS)ÚFallbackAsyncAdaptedQueueN)rrrr_r`rar rVrrrrrbBsrb)rÚ
__future__rrXÚ collectionsrr=rrJr_rrrrr    r
Z concurrencyr r Z langhelpersrrÚ__all__Ú    ExceptionrrrrrTrbrrrrÚ<module>    s0             
Q