hyb
2026-01-09 4cb426cb3ae31e772a09d4ade5b2f0242aaeefa0
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Ë
 
çúhØ1ãó˜—ddlZddlZddlZddlZddlmZmZddlm    Z    m
Z
ddl m Z m Z ddlmZej e«ZGd„d«Zy)éN)ÚSimpleNamespaceÚ TracebackType)ÚOptionalÚType)Ú    LockErrorÚLockNotOwnedError)ÚNumbercób—eZdZdZdZdZdZdZdZdZ                            d#de
de e de d    e d
e e d e d e fd „Zd$d„Zd%d„Zde eede ede eddfd„Z                d&de e d    e e d
e e de e
fd„Zde
de fd„Zde fd„Zde fd„Zd$d„Zde
ddfd„Zd'de de de fd„Zde de de fd „Zde fd!„Zde fd"„Zy)(ÚLockzï
    A shared, distributed Lock. Using Redis for locking allows the Lock
    to be shared across processes and/or machines.
 
    It's left to the user to resolve deadlock issues and make sure
    multiple clients play nicely together.
    Nz¹
        local token = redis.call('get', KEYS[1])
        if not token or token ~= ARGV[1] then
            return 0
        end
        redis.call('del', KEYS[1])
        return 1
    a÷
        local token = redis.call('get', KEYS[1])
        if not token or token ~= ARGV[1] then
            return 0
        end
        local expiration = redis.call('pttl', KEYS[1])
        if not expiration then
            expiration = 0
        end
        if expiration < 0 then
            return 0
        end
 
        local newttl = ARGV[2]
        if ARGV[3] == "0" then
            newttl = ARGV[2] + expiration
        end
        redis.call('pexpire', KEYS[1], newttl)
        return 1
    zÆ
        local token = redis.call('get', KEYS[1])
        if not token or token ~= ARGV[1] then
            return 0
        end
        redis.call('pexpire', KEYS[1], ARGV[2])
        return 1
    ÚnameÚtimeoutÚsleepÚblockingÚblocking_timeoutÚ thread_localÚraise_on_release_errorc    ó&—||_||_||_||_||_||_t |«|_||_|jrtj«n    t«|_
d|j_ |j«y)aß
        Create a new Lock instance named ``name`` using the Redis client
        supplied by ``redis``.
 
        ``timeout`` indicates a maximum life for the lock in seconds.
        By default, it will remain locked until release() is called.
        ``timeout`` can be specified as a float or integer, both representing
        the number of seconds to wait.
 
        ``sleep`` indicates the amount of time to sleep in seconds per loop
        iteration when the lock is in blocking mode and another client is
        currently holding the lock.
 
        ``blocking`` indicates whether calling ``acquire`` should block until
        the lock has been acquired or to fail immediately, causing ``acquire``
        to return False and the lock not being acquired. Defaults to True.
        Note this value can be overridden by passing a ``blocking``
        argument to ``acquire``.
 
        ``blocking_timeout`` indicates the maximum amount of time in seconds to
        spend trying to acquire the lock. A value of ``None`` indicates
        continue trying forever. ``blocking_timeout`` can be specified as a
        float or integer, both representing the number of seconds to wait.
 
        ``thread_local`` indicates whether the lock token is placed in
        thread-local storage. By default, the token is placed in thread local
        storage so that a thread only sees its token, not a token set by
        another thread. Consider the following timeline:
 
            time: 0, thread-1 acquires `my-lock`, with a timeout of 5 seconds.
                     thread-1 sets the token to "abc"
            time: 1, thread-2 blocks trying to acquire `my-lock` using the
                     Lock instance.
            time: 5, thread-1 has not yet completed. redis expires the lock
                     key.
            time: 5, thread-2 acquired `my-lock` now that it's available.
                     thread-2 sets the token to "xyz"
            time: 6, thread-1 finishes its work and calls release(). if the
                     token is *not* stored in thread local storage, then
                     thread-1 would see the token value as "xyz" and would be
                     able to successfully release the thread-2's lock.
 
        ``raise_on_release_error`` indicates whether to raise an exception when
        the lock is no longer owned when exiting the context manager. By default,
        this is True, meaning an exception will be raised. If False, the warning
        will be logged and the exception will be suppressed.
 
        In some use cases it's necessary to disable thread local storage. For
        example, if you have code where one thread acquires a lock and passes
        that lock instance to a worker thread to release later. If thread
        local storage isn't disabled in this case, the worker thread won't see
        the token set by the thread that acquired the lock. Our assumption
        is that these cases aren't common and as such default to using
        thread local storage.
        N)Úredisr r rrrÚboolrrÚ    threadingÚlocalrÚtokenÚregister_scripts)    Úselfrr r rrrrrs             õ]H:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\redis/lock.pyÚ__init__z Lock.__init__Osx€ðDˆŒ
؈Œ    ØˆŒ ؈Œ
Ø ˆŒ Ø 0ˆÔÜ  Ó.ˆÔØ&<ˆÔ#Ø*.×*;Ò*;”Y—_‘_Ô&ÄÓARˆŒ
؈
‰
ÔØ ×ÑÕóÚreturncó>—|j}|j}|j€ |j|j«|_|j
€ |j|j «|_|j€!|j|j«|_yy)N)    Ú    __class__rÚ lua_releaseÚregister_scriptÚLUA_RELEASE_SCRIPTÚ
lua_extendÚLUA_EXTEND_SCRIPTÚ lua_reacquireÚLUA_REACQUIRE_SCRIPT)rÚclsÚclients   rrzLock.register_scriptss‚€Øn‰nˆØ—‘ˆØ ?‰?Ð "Ø$×4Ñ4°S×5KÑ5KÓLˆCŒOØ >‰>Ð !Ø#×3Ñ3°C×4IÑ4IÓJˆCŒNØ × Ñ Ð $Ø &× 6Ñ 6°s×7OÑ7OÓ PˆCÕ ð %rcóT—|j«r|Std|j¬«‚)Nz0Unable to acquire lock within the time specified©Ú    lock_name)Úacquirerr ©rs rÚ    __enter__zLock.__enter__§s'€Ø <‰<Œ>؈KÜØ >Ø—i‘iô
ð    
rÚexc_typeÚ    exc_valueÚ    tracebackc󈗠   |j«y#t$r%|jr‚tj    d«YywxYw)NzBLock was unlocked or no longer owned when exiting context manager.)ÚreleaserrÚloggerÚwarning)rr0r1r2s    rÚ__exit__z Lock.__exit__¯s:€ð     Ø L‰LNøÜò    Ø×*Ò*ØÜ N‰NØTö ð    ús‚“+AÁArcóø—|€ |j}|€-tj«jj    «}n+|j
j «}|j    |«}|€ |j}|€ |j}d}|tj«|z}    |j|«r||j_ y|sytj«|z}|||kDrytj|«Œ[)as
        Use Redis to hold a shared, distributed lock named ``name``.
        Returns True once the lock is acquired.
 
        If ``blocking`` is False, always return immediately. If the lock
        was acquired, return True, otherwise return False.
 
        ``blocking_timeout`` specifies the maximum number of seconds to
        wait trying to acquire the lock.
 
        ``token`` specifies the token value to be used. If provided, token
        must be a bytes object or a string that can be encoded to a bytes
        object with the default encoding. If a token isn't specified, a UUID
        will be generated.
        NTF)rÚuuidÚuuid1ÚhexÚencoderÚ get_encoderrrÚmod_timeÚ    monotonicÚ
do_acquirerr)rrrrrÚencoderÚstop_trying_atÚ next_try_ats        rr-z Lock.acquire¾sé€ð, ˆ=Ø—J‘JˆEØ ˆ=Ü—J‘J“L×$Ñ$×+Ñ+Ó-‰Eà—j‘j×,Ñ,Ó.ˆGØ—N‘N 5Ó)ˆEØ Ð Ø—}‘}ˆHØ Ð #Ø#×4Ñ4Ð ØˆØ Ð 'Ü%×/Ñ/Ó1Ð4DÑDˆNØØ‰˜uÔ%Ø#(—
‘
Ô ØÙØÜ"×,Ñ,Ó.°Ñ6ˆKØÐ)¨k¸NÒ.JØÜ N‰N˜5Ô !ðrcó¦—|jrt|jdz«}nd}|jj|j|d|¬«ryy)NéèT)ÚnxÚpxF)r ÚintrÚsetr )rrr s   rr@zLock.do_acquireísC€Ø <Š<ä˜$Ÿ,™,¨Ñ-Ó.‰GàˆGØ :‰:>‰>˜$Ÿ)™) U¨t¸ˆ>Ô @ØØrcóP—|jj|j«duS)zU
        Returns True if this key is locked by any process, otherwise False.
        N)rÚgetr r.s rÚlockedz Lock.locked÷s €ðz‰z~‰~˜dŸi™iÓ(°Ð4Ð4rcó,—|jj|j«}|r;t|t«s+|jj «}|j |«}|jjduxr||jjk(S)zS
        Returns True if this key is locked by this lock, otherwise False.
        N)    rrKr Ú
isinstanceÚbytesr=r<rr)rÚ stored_tokenrAs   rÚownedz
Lock.ownedýsq€ð—z‘z—~‘~ d§i¡iÓ0ˆ ñ ¤
¨<¼Ô ?Ø—j‘j×,Ñ,Ó.ˆGØ"Ÿ>™>¨,Ó7ˆL؏z‰z×Ñ tÐ+ÒP° ÀÇ
Á
×@PÑ@PÑ0PÐPrcó¦—|jj}|€td|j¬«‚d|j_|j    |«y)z4
        Releases the already acquired lock
        Nz>Cannot release a lock that's not owned or is already unlocked.r+)rrrr Ú
do_release©rÚexpected_tokens  rr4z Lock.release    sJ€ðŸ™×)Ñ)ˆØ Ð !ÜØPØŸ)™)ôð 𠈏
‰
ÔØ ‰˜Õ'rrUcó˜—t|j|jg|g|j¬««st    d|j¬«‚y)N©ÚkeysÚargsr)z,Cannot release a lock that's no longer ownedr+)rr!r rrrTs  rrSzLock.do_releasesJ€ÜØ × Ñ  4§9¡9 +°^Ð4DÈTÏZÉZÐ Ó Xô
ô$Ø>ØŸ)™)ôð ð
rÚadditional_timeÚ replace_ttlcóƗ|jj€td|j¬«‚|j€td|j¬«‚|j ||«S)ah
        Adds more time to an already acquired lock.
 
        ``additional_time`` can be specified as an integer or a float, both
        representing the number of seconds to add.
 
        ``replace_ttl`` if False (the default), add `additional_time` to
        the lock's existing ttl. If True, replace the lock's ttl with
        `additional_time`.
        zCannot extend an unlocked lockr+z$Cannot extend a lock with no timeout)rrrr r Ú    do_extend©rrZr[s   rÚextendz Lock.extendsS€ð :‰:× Ñ Ð #ÜÐ<ÈÏ    É    ÔRÐ RØ <‰<Ð ÜÐBÈdÏiÉiÔXÐ X؏~‰~˜o¨{Ó;Ð;rcóè—t|dz«}t|j|jg|jj
||rdndg|j ¬««std|j¬«‚y)NrEÚ1Ú0rWz+Cannot extend a lock that's no longer ownedr+T)rHrr$r rrrrr^s   rr]zLock.do_extend0sq€Ü˜o°Ñ4Ó5ˆÜØ O‰OØ—i‘i[Ø—j‘j×&Ñ&¨Á ¹ÐQTÐUØ—z‘zð ó ô
ô$Ø=ØŸ)™)ôð ðrcó—|jj€td|j¬«‚|j€td|j¬«‚|j «S)zS
        Resets a TTL of an already acquired lock back to a timeout value.
        z!Cannot reacquire an unlocked lockr+z'Cannot reacquire a lock with no timeout)rrrr r Ú do_reacquirer.s rÚ    reacquirezLock.reacquire?sX€ð :‰:× Ñ Ð #ÜÐ?È4Ï9É9ÔUÐ UØ <‰<Ð ÜØ9ØŸ)™)ôð ð× Ñ Ó"Ð"rcóò—t|jdz«}t|j|jg|j
j |g|j¬««std|j¬«‚y)NrErWz.Cannot reacquire a lock that's no longer ownedr+T)    rHr rr&r rrrr)rr s  rrdzLock.do_reacquireLsn€Üd—l‘l TÑ)Ó*ˆÜØ × Ñ Ø—i‘i[¨¯
©
×(8Ñ(8¸'Ð'BÈ4Ï:É:ð ó ô
ô
$Ø@ØŸ)™)ôð ðr)Ngš™™™™™¹?TNTT)rN)rr )NNNN)F)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r!r$r&r#r%r'Ústrrr    rrrr/rÚ BaseExceptionrr7r-r@rLrQr4rSr_r]rerd©rrr r sÉ„ñð€KØ€JØ€Mð
ÐðÐð2Ðð%)ØØØ-1Ø!Ø'+ñL ððL ð˜&Ñ!ð    L ð
ð L ð ð L ð# 6Ñ*ðL ððL ð!%óL ó\Qó
ð à˜4  Ñ.Ñ/ð ð˜MÑ*ð ð˜MÑ*ð     ð
 
ó ð"#'Ø#'Ø-1Ø#ñ -"à˜Ñð-"ð˜4‘.ð-"ð# 6Ñ*ð    -"ð
˜‰}ó -"ð^ ð¨óð5˜ó5ð
Qtó
Qó (ð¨ð°óñ< fð<¸4ð<ÈDó<ð" ¨ð ¸dð Àtó ð #˜4ó #ð ˜dô rr )ÚloggingrÚtimer>r9ÚtypesrrÚtypingrrÚredis.exceptionsrrÚ redis.typingr    Ú    getLoggerrgr5r rmrrú<module>rus;ðÛÛÛÛ ß0ß!ç9Ýà    ˆ×    Ñ    ˜8Ó    $€÷IòIr