Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
locks.cpython-314.pyc244 linesDownload Raw Back to __pycache__
1+
2��i^P��b�RtRt^RIt^RIt^RIHt^R	IHt!R3R4t!RR]]P4t	!R
R]P4t4!RR]]P4t!RR]]P4t!RR]4t
!RR]P4t!RR]P4tR#)zSynchronization primitives.�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�BarrierN)�5exceptions)�mixinsc�,a�]tRt^toRtRtRtVtR#)�_ContextManagerMixinc��B"�VP4GRjx�L6R#L5i�N)�acquire��selfs&�Lib\asyncio\locks.py�7__aenter__�_ContextManagerMixin.__aenter__
s����l�l�n����	�s���c��."�VP4R#5ir
)�release)r�exc_type�exc�tbs&&&&r�	__aexit__�_ContextManagerMixin.__aexit__s�������s��N)�__name__�8__module__�__qualname__�__firstlineno__rr�__static_attributes__�__classdictcell__)�
__classdict__s@rrrs�������rc�Taa�]tRt^toRtRtV3RltRtRtRt	Rt9RtVtV;t
#)	ra�Primitive lock objects.10 11A primitive lock is a synchronization primitive that is not owned12by a particular task when locked.  A primitive lock is in one13of two states, 'locked' or 'unlocked'.14 15It is created in the unlocked state.  It has two basic methods,16acquire() and release().  When the state is unlocked, acquire()17changes the state to locked and returns immediately.  When the18state is locked, acquire() blocks until a call to release() in19another task changes it to unlocked, then the acquire() call20resets it to locked and returns.  The release() method should only21be called in the locked state; it changes the state to unlocked22and returns immediately.  If an attempt is made to release an23unlocked lock, a RuntimeError will be raised.24 25When more than one task is blocked in acquire() waiting for26the state to turn to unlocked, only one task proceeds when a27release() call resets the state to unlocked; successive release()28calls will unblock tasks in FIFO order.29 30Locks also support the asynchronous context management protocol.31'async with lock' statement should be used.32 33Usage:34 35    lock = Lock()36    ...37    await lock.acquire()38    try:39        ...40    finally:41        lock.release()42 43Context manager usage:44 45    lock = Lock()46    ...47    async with lock:48         ...49 50Lock objects can be tested for locking state:51 52    if not lock.locked():53       await lock.acquire()54    else:55       # lock is acquired56       ...57 58c�"�RVnRVnR#)NF)�_waiters�_lockedrs&r�__init__�
Lock.__init__Ks����
���r#c�<�\SV`4pVP'dRMRpVP'dVR\	VP42pRV^RRVR2#��locked�unlocked�59, waiters:�<� [�]>�����)�super�__repr__r'r&�len�r�res�extra�	__class__s&  �rr4�
Lock.__repr__Os]����g�� �� �L�L�L��j���=�=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)r#c��VP#)z Return True if lock is acquired.)r'rs&rr,�Lock.lockedVs���|�|�r#c���"�VP'gfVPeO\;QJd&RVP4F'dKRM	RM!RVP44'd60RVnR#VPf\P!4VnVP4P
4pVPPV4VGRjx�L61VPPV4RTnR#L( TPPT4i;i \Pd%TP'gTP4hi;i5i)ziAcquire a lock.62 63This method blocks until the lock is unlocked, then sets it to64locked and returns True.65Nc3�@"�TFqP4x�K	R#5ir
��	cancelled��.0�ws& r�	<genexpr>�Lock.acquire.<locals>.<genexpr>cs���9�=�a�K�K�M�M�=�s�FT)r'r&�all�collections�deque�	_get_loop�
create_future�append�remover�CancelledError�_wake_up_first�r�futs& rr�Lock.acquireZs�������$�-�-�"7���9�4�=�=�9����9�4�=�=�9�9�9��D�L���=�=� �'�-�-�/�D�M��n�n��,�,�.���
�
���S�!�
	�
*��	�	��
�
�$�$�S�)��������
�
�$�$�S�)���(�(�	��<�<�<��#�#�%��	�sY�+E)�E)�$E)�1A*E)�D
�"D�#D
�'D-�	E)�D
�
D*�*D-�-&E&�E&�&E)c�n�VP'dRVnVP4R#\R4h)aRelease a lock.66 67When the lock is locked, reset it to unlocked, and return.68If any other tasks are blocked waiting for the lock to become69unlocked, allow exactly one of them to proceed.70 71When invoked on an unlocked lock, a RuntimeError is raised.72 73There is no return value.74FzLock is not acquired.N)r'rN�RuntimeErrorrs&rr�Lock.releases,���<�<�<� �D�L����!��6�7�7r#c���VP'gR#\\VP44pTP	4'gTPR4R#R# \dR#i;i)z*Ensure that the first waiter will wake up.NT)r&�next�iter�
StopIteration�done�75set_resultrOs& rrN�Lock._wake_up_first�sX���}�}�}��	��t�D�M�M�*�+�C�76�x�x�z�z��N�N�4� ���	�	��	�s�A�A.�-A.)r'r&)rrrr�__doc__r(r4r,rrrNr r!�
__classcell__�r9r"s@@rrrs/����1�f�*��#�J8�"!�!r#c�Taa�]tRt^�toRtRtV3RltRtRtRt	Rt77RtVtV;t
#)	raAsynchronous equivalent to threading.Event.78 79Class implementing event objects. An event manages a flag that can be set80to true with the set() method and reset to false with the clear() method.81The wait() method blocks until the flag is true. The flag is initially82false.83c�H�\P!4VnRVnR#)FN)rGrHr&�_valuers&rr(�Event.__init__�s��#�)�)�+��
���r#c�<�\SV`4pVP'dRMRpVP'dVR\	VP42pRV^RRVR2#)�set�unsetr.r/r0r1r2)r3r4rar&r5r6s&  �rr4�Event.__repr__�s]����g�� �������'���=�=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)r#c��VP#)z5Return True if and only if the internal flag is true.�rars&r�is_set�Event.is_set�s���{�{�r#c��VP'gFRVnVPF,pVP4'dKVPR4K.	R#R#)z�Set the internal flag to true. All tasks waiting for it to84become true are awakened. Tasks that call wait() once the flag is85true will not block at all.86TN)rar&rYrZrOs& rrd�	Event.set�s>��87�{�{�{��D�K��}�}���x�x�z�z��N�N�4�(�%�r#c��RVnR#)z�Reset the internal flag to false. Subsequently, tasks calling88wait() will block until set() is called to set the internal flag89to true again.FNrhrs&r�clear�Event.clear�s����r#c��:"�VP'dR#VP4P4pVPP	V4VGRjx�L90VPPV4R#L" TPPT4i;i5i)z�Block until the internal flag is true.91 92If the internal flag is true on entry, return True93immediately.  Otherwise, block until another task calls94set() to set the flag to true, then return True.95TN)rarIrJr&rKrLrOs& r�wait�96Event.wait�su����;�;�;���n�n��,�,�.���
�
���S�!�	&��I�I���M�M� � ��%�
��
�M�M� � ��%�s0�AB�A;�A9�A;�B�9A;�;B�B�rar&)rrrrr\r(r4rirdrnrqr r!r]r^s@@rrr�s-������*��97)��&�&r#c�baa�]tRt^�toRtR98RltV3RltRtRtRRlt	Rt99RtR	tVt
V;t#)raAsynchronous equivalent to threading.Condition.100 101This class implements condition variable objects. A condition variable102allows one or more tasks to wait until they are notified by another103task.104 105A new Lock object is created and used as the underlying lock.106c���Vf\4pWnVPVnVPVnVPVn\107P!4VnR#r
)r�_lockr,rrrGrHr&)r�locks&&rr(�Condition.__init__�sD���<��6�D��108��k�k����|�|����|�|���#�)�)�+��
r#c��<�\SV`4pVP4'dRMRpVP'dVR\	VP42pRV^RRVR2#r+)r3r4r,r&r5r6s&  �rr4�Condition.__repr__�s_����g�� �� �K�K�M�M��z���=�=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)r#c��109"�VP4'g\R4hVP4P4pVP	4VP110P
V4VGRjx�L111VP112PV4RpVP4GRjx�L113TeThR#LFL \PdpTpRp?KERp?ii;i Rpi;i TP114PT4i;i RpTP4GRjx�L115M% \PdpTpRp?K9Rp?ii;iTeTh Rpi;ii;i \dTP^4hi;i5i)a�Wait until notified.116 117If the calling task has not acquired the lock when this118method is called, a RuntimeError is raised.119 120This method releases the underlying lock, and then blocks121until it is awakened by a notify() or notify_all() call for122the same condition variable in another task.  Once123awakened, it re-acquires the lock and returns True.124 125This method may return spuriously,126which is why the caller should always127re-check the state and be prepared to wait() again.128zcannot wait on un-acquired lockNT)
r,rSrIrJrr&rKrLrrrM�
BaseException�_notify)rrP�err�es&   rrq�Condition.wait�sk����{�{�}�}��@�A�A��n�n��,�,�.������!	�
#��
�
�$�$�S�)�.��I�I���M�M�(�(��-���� �"�l�l�n�,�,���?�#�!�	�#�#�-��%�4�4� ���� ��#���%�M�M�(�(��-����� �"�l�l�n�,�,���%�4�4� ���� ���?�#�!�	��"���	#��129�	�
�L�L��O��	�s��AF�D�0C,�5B<�6C,�;D�E"�C�-B>�.C�2E"�8C%�:F�<C,�>C�C"�C�E"�C"�"E"�%C)�)E"�,D	�	D�E�D+�$D'�%D+�*E�+E
�E�E�E
�
E�E�E�E�E"�"F�Fc��r"�V!4pV'g"VP4GRjx�L130V!4pK)V#L5i)z�Wait until a predicate becomes true.131 132The predicate should be a callable whose result will be133interpreted as a boolean value.  The method will repeatedly134wait() until it evaluates to true.  The final predicate value is135the return value.136N�rq)r�	predicate�results&& r�wait_for�Condition.wait_for/s1��������)�)�+����[�F��
�
�s�7�7�5�7c�j�VP4'g\R4hVPV4R#)a�By default, wake up one task waiting on this condition, if any.137If the calling task has not acquired the lock when this method138is called, a RuntimeError is raised.139 140This method wakes up n of the tasks waiting for the condition141 variable; if fewer than n are waiting, they are all awoken.142 143Note: an awakened task does not actually return from its144wait() call until it can reacquire the lock. Since notify() does145not release the lock, its caller should.146z!cannot notify on un-acquired lockN)r,rSr})r�ns&&r�notify�Condition.notify=s&���{�{�}�}��B�C�C����Q�r#c��^pVPF>pW!8�dR#VP4'dK$V^,
pVPR4K@	R#)�FN)r&rYrZ)rr��idxrPs&&  rr}�Condition._notifyMs=�����=�=�C��x���8�8�:�:��q������u�%�
!r#c�N�VP\VP44R#)z�Wake up all tasks waiting on this condition. This method acts147like notify(), but wakes up all waiting tasks instead of one. If the148calling task has not acquired the lock when this method is called,149a RuntimeError is raised.150N)r�r5r&rs&r�151notify_all�Condition.notify_allWs��	
���C��
�
�&�'r#)rvr&rr,rr
��)rrrrr\r(r4rqr�r�r}r�r r!r]r^s@@rrr�s3�����152,�*�5�n�� &�(�(r#c�Xaa�]tRtRtoRtR153RltV3RltRtRtRt	Rt154R	tVtV;t
#)ri`a�A Semaphore implementation.155 156A semaphore manages an internal counter which is decremented by each157acquire() call and incremented by each release() call. The counter158can never go below zero; when acquire() finds that it is zero, it blocks,159waiting until some other thread calls release().160 161Semaphores also support the context management protocol.162 163The optional argument gives the initial value for the internal164counter; it defaults to 1. If the value given is less than 0,165ValueError is raised.166c�D�V^8d\R4hRVnWnR#)r�z$Semaphore initial value must be >= 0N)�167ValueErrorr&ra)r�values&&rr(�Semaphore.__init__os!���1�9��C�D�D���
��r#c��<�\SV`4pVP4'dRMRVP2pVP'dVR\VP42pRV^RRVR2#)r,zunlocked, value:r.r/r0r1r2)r3r4r,rar&r5r6s&  �rr4�Semaphore.__repr__usk����g�� �� �K�K�M�M��1A�$�+�+��/O���=�=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)r#c���VP^8H;'g]\;QJd0RVP;'gR4F'gKR#	R#!RVP;'gR44#)z9Returns True if semaphore cannot be acquired immediately.c3�J"�TFqP4'*x�K	R#5ir
r?rAs& rrD�#Semaphore.locked.<locals>.<genexpr>�s���A�,?�a�K�K�M�!�!�,?�s�!#TFr)ra�anyr&rs&rr,�Semaphore.locked|sn���{�{�a��C�C��C�A�D�M�M�,?�,?�R�,?�A�C�C�	C��	C��A�D�M�M�,?�,?�R�,?�A�A�	Cr#c��<"�VP4'gV;P^,unR#VPf\P!4VnVP4P
4pVPPV4VGRjx�L168VPPV4TP^8�dTP4'dK)R#R#LO TPPT4i;i \PdHTP4'd0TP4'gT;P^,
unhi;i TP^8�dTP4'dK)ii;i5i)aAcquire a semaphore.169 170If the internal counter is larger than zero on entry,171decrement it by one and return True immediately.  If it is172zero on entry, block, waiting until some other task has173called release() to make it larger than 0, and then return174True.175TN)r,rar&rGrHrIrJrKrLrrMrYr@�
_wake_up_nextrOs& rr�Semaphore.acquire�s,����{�{�}�}��K�K�1��K���=�=� �'�-�-�/�D�M��n�n��,�,�.���
�
���S�!�	�
*��	�	��
�
�$�$�S�)��+�+��/��)�)�+�+���"��'���
�
�$�$�S�)���(�(�	��x�x�z�z�#�-�-�/�/�176���q� ���	���+�+��/��)�)�+�+��"�sf�BF�C.�C,�C.�!D�=$F�&F�,C.�.D�D�*E*�9E*�E*�*E-�-%F�F�Fc�X�V;P^,
unVP4R#)z�Release a semaphore, incrementing the internal counter by one.177 178When it was zero on entry and another task is waiting for it to179become larger than zero again, wake up that task.180N)rar�rs&rr�Semaphore.release�s��	
���q������r#c���VP'gR#VPFFpVP4'dKV;P^,unVPR4R#	R#)z)Wake up the first waiter that isn't done.FT)r&rYrarZrOs& rr��Semaphore._wake_up_next�sI���}�}�}���=�=�C��8�8�:�:����q� �����t�$��!�r#rsr�)rrrrr\r(r4r,rrr�r r!r]r^s@@rrr`s/������*�C�(�T��r#c�Faa�]tRtRtoRtRV3RlltV3RltRtVtV;t	#)ri�z�A bounded semaphore implementation.181 182This raises ValueError in release() if it would increase the value183above the initial value.184c�2<�Wn\SV`	V4R#r
)�_bound_valuer3r()rr�r9s&&�rr(�BoundedSemaphore.__init__�s���!��
����r#c�p<�VPVP8�d\R4h\SV`4R#)z(BoundedSemaphore released too many timesN)rar�r�r3r)rr9s&�rr�BoundedSemaphore.release�s+����;�;�$�+�+�+��G�H�H�
���r#)r�r�)185rrrrr\r(rr r!r]r^s@@rrr�s����� ��r#c�&�]tRtRtRtRtRtRtRtR#)�
_BarrierStatei��filling�draining�	resetting�brokenrN)	rrrr�FILLING�DRAINING�	RESETTING�BROKENr rr#rr�r��s���G��H��I�
�Fr#r�c�aa�]tRtRtoRtRtV3RltRtRtRt	Rt186R	tR187tRt
RtR
t]R4t]R4t]R4tRtVtV;t#)ri�z�Asyncio equivalent to threading.Barrier188 189Implements a Barrier primitive.190Useful for synchronizing a fixed number of tasks at known synchronization191points. Tasks block on 'wait()' and are simultaneously awoken once they192have all made their call.193c��V^8d\R4h\4VnWn\P194Vn^VnR#)z1Create a barrier, initialised to 'parties' tasks.zparties must be >= 1N)r�r�_cond�_partiesr�r��_state�_count)r�partiess&&rr(�Barrier.__init__�s7���Q�;��3�4�4��[��195��
�#�+�+�����r#c��<�\SV`4pVPPpVP'g$VRVP196RVP2,
pRV^RRVR2#)r.�/r/r0r1r2)r3r4r�r�r��	n_waitingr�r6s&  �rr4�Barrier.__repr__�sf����g�� ���;�;�$�$�%���{�{�{��z�$�.�.�!1��4�<�<�.�A�A�E��3�q��9�+�R��w�b�)�)r#c��>"�VP4GRjx�L197#L5ir
r�rs&rr�Barrier.__aenter__�s����Y�Y�[� � � �s���c��"�R#5ir
r)r�argss&*rr�Barrier.__aexit__�s����s�c��v"�VP;_uu_4GRjx�L198VP4GRjx�L199VPpV;P^,
unV^,VP8XdVP	4GRjx�L200MVP4GRjx�L201TV;P^,unVP
4uuRRR4GRjx�L202#L�L�L^LGL
 T;P^,unTP
4i;i +GRjx�L203'giR#;i5i)z�Wait for the barrier.204 205When the specified number of tasks have started waiting, they are all206simultaneously awoken.207Returns an unique and individual index number from 0 to 'parties-1'.208N)r��_blockr�r��_release�_wait�_exit)r�indexs& rrq�Barrier.wait�s�����:�:�:�:��+�+�-���
��������q� ���1�9��
�
�-��-�-�/�)�)��*�*�,�&�&�����q� ���209�210���:�:��*�&������q� ���211�212����:�:�:�s��D9�C$�D9�D�C&�D�AC.�	C(�213C.�"C*�#C.�()D�
D9�C,�D9�&D�(C.�*C.�,D9�.+D�D�D6	�"D%�#214D6	�.D6	�0	D9c���a"�SPPV3Rl4GRjx�L215SP\PJd\216P!R4hR#L:5i)c�^<�SP\P\P39#r
)r�r�r�r�rs�r�<lambda>� Barrier._block.<locals>.<lambda>s$���D�K�K��&�&�
�(?�(?�(�r#NzBarrier aborted)r�r�r�r�r�r�BrokenBarrierErrorrsfrr��Barrier._blocksY�����j�j�!�!�
�217�	218�	219��;�;�-�.�.�.��/�/�0A�B�B�/�	220�s�#A#�A!�;A#c��l"�\PVnVPP	4R#5ir
)r�r�r�r�r�rs&rr��Barrier._release&s$���221$�,�,����222�223����s�24c���a"�SPPV3Rl4GRjx�L224SP\P\P22539d\P!R4hR#LK5i)c�<<�SP\PJ#r
)r�r�r�rs�rr��Barrier._wait.<locals>.<lambda>4s���$�+�+�]�=R�=R�*Rr#NzAbort or reset of barrier)r�r�r�r�r�r�rr�rsfrr��
Barrier._wait.s\�����j�j�!�!�"R�S�S�S��;�;�=�/�/��1H�1H�I�I��/�/�0K�L�L�J�	T�s�#A4�A2�AA4c���VP^8XdaVP\P\P39d\P226VnVPP4R#R#)r�N)r�r�r�r�r�r�r�r�rs&rr��
Barrier._exit9sO���;�;�!���{�{�}�6�6�
�8N�8N�O�O�+�3�3����J�J�!�!�#�r#c��"�VP;_uu_4GRjx�L227VP^8�d5VP\PJd\PVnM\P228VnVPP
4RRR4GRjx�L229R#L�L +GRjx�L230'giR#;i5i)zrReset the barrier to the initial state.231 232Any tasks currently waiting will get the BrokenBarrier exception233raised.234N)r�r�r�r�r�r�r�rs&r�reset�
Barrier.resetAsi����:�:�:�:��{�{�Q���;�;�m�&=�&=�=�"/�"9�"9�D�K��+�3�3����J�J�!�!�#��:�:�:�:�:�sK�C�B&�C�A5B*�C�B(� C�(C�*C	�0B3�1235C	�<C	�>	Cc��"�VP;_uu_4GRjx�L236\PVnVPP	4RRR4GRjx�L237R#LEL +GRjx�L238'giR#;i5i)z�Place the barrier into a 'broken' state.239 240Useful in case of error.  Any currently waiting tasks and tasks241attempting to 'wait()' will have BrokenBarrierError raised.242N)r�r�r�r�r�rs&r�abort�
Barrier.abortPs>����:�:�:�:�'�.�.�D�K��J�J�!�!�#��:�:�:�:�:�sJ�B�A!�B�0A%�B�A#�B�#B�%A?	�+A.�,243A?	�7A?	�9	Bc��VP#)z8Return the number of tasks required to trip the barrier.)r�rs&rr��Barrier.partiesZs���}�}�r#c�Z�VP\PJd
VP#^#)z<Return the number of tasks currently waiting at the barrier.)r�r�r�r�rs&rr��Barrier.n_waiting_s#���;�;�-�/�/�/��;�;��r#c�:�VP\PJ#)z0Return True if the barrier is in a broken state.)r�r�r�rs&rr��Barrier.brokenfs���{�{�m�2�2�2�2r#)r�r�r�r�)rrrrr\r(r4rrrqr�r�r�r�r�r��propertyr�r�r�r r!r]r^s@@rrr�s������	�*�!�244
��.C�  �	M�$�
$�$����������3��3�3r#)rrrrrr)r\�__all__rG�enum�rr	r�_LoopBoundMixinrrrrr�Enumr�rrr#r�<module>r�s���!�*��������D!���!7�!7�D!�N:&�F�"�"�:&�zB(�$�f�&<�&<�B(�J`�$�f�&<�&<�`�F�y��$�D�I�I��M3�f�$�$�M3r#
codekingpro/portable-devtools · Team Ai