Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
ioloop.cpython-313.pyc528 linesDownload Raw Back to __pycache__
1�

2��j����SrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK3r4SSKrSSKrSSK
Jr SSKJrJrJrJrJr SSKJr SSKJrJrJr SSKrSSKJrJrJrJrJ r J!r!J"r"J#r# \RH(aSSKJ%r%J&r&J'r'J(r( SS	K)J*r* O\+r*"S5S\*5r,\!"S5r-\!"S
\,S9r."SS\5r/"SS5r0"SS5r1g)a�An I/O event loop for non-blocking sockets.6 7In Tornado 6.0, `.IOLoop` is a wrapper around the `asyncio` event loop, with a8slightly different interface. The `.IOLoop` interface is now provided primarily9for backwards compatibility; new code should generally use the `asyncio` event10loop interface directly. The `IOLoop.current` class method provides the11`IOLoop` instance corresponding to the running `asyncio` event loop.12 13�N)�isawaitable)�Future�	is_future�chain_future�future_set_exc_info�future_add_done_callback)�app_log)�Configurable�TimeoutError�
import_object)�Union�Any�Type�Optional�Callable�TypeVar�Tuple�	Awaitable)�Dict�List�Set�	TypedDict)�Protocolc�,�\rSrSrS\4SjrSSjrSrg)�_Selectable�<�returnc��g�N���selfs �TD:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/ioloop.py�fileno�_Selectable.fileno=����Nc��grr r!s r#�close�_Selectable.close@r&r'r �rN)�__name__�14__module__�__qualname__�__firstlineno__�intr$r)�__static_attributes__r r'r#rr<s��
��
�
r'r�_T�_S)�boundc15�F^�\rSrSrSrSrSrSrSr\	"5r16\"5r\
SSS	\S17S4U4Sjj5r\SJS
j5rSKSjr\SKSj5r\R*\SJSj55r\R*\SLS\S18\S4Sjj55r\SLS\S19\S4Sjj5rSKSjrSKSjr\SKSj5r\SKSj5rSKSjr\
S20\\4Sj5r \
S21\\4Sj5r!SLS\S22S4Sjjr"SMS\S23S4Sjjr#\R*S\$S \%\$\$/S4S!\$S24S4S"j5r&\R*S\'S \%\'\$/S4S!\$S25S4S#j5r&S\(\$\)4S \%S$S!\$S26S4S%jr&S\(\$\)4S!\$S27S4S&jr*S\(\$\)4S28S4S'jr+SKS(jr,SKS)jr-SNS*\%S+\\.S29\4S,jjr/S30\.4S-jr0S.\(\.\1Rd4S/\%S0\S	\S31\3432S1jr4S2\.S/\%S0\S	\S33\3434S3jr5S4\.S/\%S0\S	\S35\3436S5jr6S+\3S37S4S6jr7S/\%S0\S	\S38S4S7jr8S/\%S0\S	\S39S4S8jr9S/\%S0\S	\S40S4S9jr:S:S;S/\%S</S4S41S4S=jr;S>\\<RzR|S*\%S?\?4S0\S42S<4S@jr@S>\<RzR|S43S4SAjrAS/\%/\4S44S4SBjrBS:\CS45S4SCjrDS\(\$\)4S46\E\$\(\$\)444SDjrFS\(\$\)4S47S4SEjrGSF\CS48S4SGjrHSF\CS49S4SHjrISIrJU=rK$)O�IOLoop�Ha�50An I/O event loop.51 52As of Tornado 6.0, `IOLoop` is a wrapper around the `asyncio` event loop.53 54Example usage for a simple TCP server:55 56.. testcode::57 58    import asyncio59    import errno60    import functools61    import socket62 63    import tornado64    from tornado.iostream import IOStream65 66    async def handle_connection(connection, address):67        stream = IOStream(connection)68        message = await stream.read_until_close()69        print("message from client:", message.decode().strip())70 71    def connection_ready(sock, fd, events):72        while True:73            try:74                connection, address = sock.accept()75            except BlockingIOError:76                return77            connection.setblocking(0)78            io_loop = tornado.ioloop.IOLoop.current()79            io_loop.spawn_callback(handle_connection, connection, address)80 81    async def main():82        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)83        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)84        sock.setblocking(0)85        sock.bind(("", 8888))86        sock.listen(128)87 88        io_loop = tornado.ioloop.IOLoop.current()89        callback = functools.partial(connection_ready, sock)90        io_loop.add_handler(sock.fileno(), callback, io_loop.READ)91        await asyncio.Event().wait()92 93    if __name__ == "__main__":94        asyncio.run(main())95 96Most applications should not attempt to construct an `IOLoop` directly,97and instead initialize the `asyncio` event loop and use `IOLoop.current()`.98In some cases, such as in test frameworks when initializing an `IOLoop`99to be run in a secondary thread, it may be appropriate to construct100an `IOLoop` with ``IOLoop(make_current=False)``.101 102In general, an `IOLoop` cannot survive a fork or be shared across processes103in any way. When multiple processes are being used, each process should104create its own `IOLoop`, which also implies that any objects which depend on105the `IOLoop` (such as `.AsyncHTTPClient`) must also be created in the child106processes. As a guideline, anything that starts processes (including the107`tornado.process` and `multiprocessing` modules) should do so as early as108possible, ideally the first thing the application does after loading its109configuration, and *before* any calls to `.IOLoop.start` or `asyncio.run`.110 111.. versionchanged:: 4.2112   Added the ``make_current`` keyword argument to the `IOLoop`113   constructor.114 115.. versionchanged:: 5.0116 117   Uses the `asyncio` event loop by default. The ``IOLoop.configure`` method118   cannot be used on Python 3 except to redundantly specify the `asyncio`119   event loop.120 121.. versionchanged:: 6.3122   ``make_current=True`` is now the default when creating an IOLoop -123   previously the default was to make the event loop current if there wasn't124   already a current one.125r����implz$Union[None, str, Type[Configurable]]�kwargsrNc��>�SSKJn [U[5(a[	U5n[U[1265(a[
X5(d[S5e[TU]$"U40UD6 g)Nr)�BaseAsyncIOLoopz5only AsyncIOLoop is allowed when asyncio is available)127�tornado.platform.asyncior>�128isinstance�strr�type�129issubclass�RuntimeError�super�	configure)�clsr;r<r>�	__class__s    �r#rF�IOLoop.configure�sT���	=��d�C� � � ��&�D��d�D�!�!�*�T�*K�*K��V�W�W�
���$�)�&�)r'c�*�[R5$)a�Deprecated alias for `IOLoop.current()`.130 131.. versionchanged:: 5.0132 133   Previously, this method returned a global singleton134   `IOLoop`, in contrast with the per-thread `IOLoop` returned135   by `current()`. In nearly all cases the two were the same136   (when they differed, it was generally used from non-Tornado137   threads to communicate back to the main thread's `IOLoop`).138   This distinction is not present in `asyncio`, so in order139   to facilitate integration with that package `instance()`140   was changed to be an alias to `current()`. Applications141   using the cross-thread communications aspect of142   `instance()` should instead set their own global variable143   to point to the `IOLoop` they want to use.144 145.. deprecated:: 5.0146)r6�currentr r'r#�instance�IOLoop.instance�s��(�~�~��r'c�$�UR5 g)a(Deprecated alias for `make_current()`.147 148.. versionchanged:: 5.0149 150   Previously, this method would set this `IOLoop` as the151   global singleton used by `IOLoop.instance()`. Now that152   `instance()` is an alias for `current()`, `install()`153   is an alias for `make_current()`.154 155.. deprecated:: 5.0156N)�make_currentr!s r#�install�IOLoop.install�s��	
���r'c�,�[R5 g)a3Deprecated alias for `clear_current()`.157 158.. versionchanged:: 5.0159 160   Previously, this method would clear the `IOLoop` used as161   the global singleton by `IOLoop.instance()`. Now that162   `instance()` is an alias for `current()`,163   `clear_instance()` is an alias for `clear_current()`.164 165.. deprecated:: 5.0166 167N)r6�
clear_currentr r'r#�clear_instance�IOLoop.clear_instance�s��	���r'c��grr r r'r#rK�IOLoop.current����	
r'rLc��grr �rLs r#rKrW�rXr'c�2�[R"5n[168RU$![a7 U(dg[R"5n[R"U5 NTf=f![a U(aSSKJ	n U"5nU$SnU$f=f)a�Returns the current thread's `IOLoop`.169 170If an `IOLoop` is currently running or has been marked as171current by `make_current`, returns that instance.  If there is172no current `IOLoop` and ``instance`` is true, creates one.173 174.. versionchanged:: 4.1175   Added ``instance`` argument to control the fallback to176   `IOLoop.instance()`.177.. versionchanged:: 5.0178   On Python 3, control of the current `IOLoop` is delegated179   to `asyncio`, with this and other methods as pass-through accessors.180   The ``instance`` argument now controls whether an `IOLoop`181   is created automatically when there is none, instead of182   whether we fall back to `IOLoop.instance()` (which is now183   an alias for this method). ``instance=False`` is deprecated,184   since even if we do not create an `IOLoop`, this method185   may initialize the asyncio loop.186 187.. deprecated:: 6.2188   It is deprecated to call ``IOLoop.current()`` when no `asyncio`189   event loop is running.190Nr)�AsyncIOMainLoop)191�asyncio�get_event_looprD�new_event_loop�set_event_loopr6�_ioloop_for_asyncio�KeyErrorr?r\)rL�loopr\rKs    r#rKrW�s���2	)��)�)�+�D�	��-�-�d�3�3���	)����)�)�+�D��"�"�4�(�	)���	��D�)�+��������	�s+�+�A/�A,�+A,�+A,�/B�B�Bc�X�[R"S[SS9 UR5 g)a�Makes this the `IOLoop` for the current thread.192 193An `IOLoop` automatically becomes current for its thread194when it is started, but it is sometimes useful to call195`make_current` explicitly before starting the `IOLoop`,196so that code run at startup time can find the right197instance.198 199.. versionchanged:: 4.1200   An `IOLoop` created while there is no current `IOLoop`201   will automatically become current.202 203.. versionchanged:: 5.0204   This method also sets the current `asyncio` event loop.205 206.. deprecated:: 6.2207   Setting and clearing the current event loop through Tornado is208   deprecated. Use ``asyncio.set_event_loop`` instead if you need this.209z6make_current is deprecated; start the event loop first���210stacklevelN)�warnings�warn�DeprecationWarning�
_make_currentr!s r#rO�IOLoop.make_current"s'��(	�
�
�D���	211�212	
���r'c��[5er��NotImplementedErrorr!s r#rk�IOLoop._make_current=s��!�#�#r'c�`�[R"S[SS9 [R	5 g)z�Clears the `IOLoop` for the current thread.213 214Intended primarily for use by test frameworks in between tests.215 216.. versionchanged:: 5.0217   This method also clears the current `asyncio` event loop.218.. deprecated:: 6.2219zclear_current is deprecatedrerfN)rhrirjr6�_clear_currentr r'r#rS�IOLoop.clear_currentAs'��	�
�
�)���	220�221	���r'c�R�[RSS9nUbUR5 gg)NFrZ)r6rK�_clear_current_hook)�olds r#rr�IOLoop._clear_currentRs(���n�n�e�n�,���?��#�#�%�r'c��g)zInstance method called when an IOLoop ceases to be current.222 223May be overridden by subclasses as a counterpart to make_current.224Nr r!s r#ru�IOLoop._clear_current_hookXs��225	
r'c��[$r)r6)rGs r#�configurable_base�IOLoop.configurable_base_s���
r'c��SSKJn U$)Nr)�AsyncIOLoop)r?r~)rGr~s  r#�configurable_default�IOLoop.configurable_defaultcs��8��r'rOc�4�U(aUR5 ggr)rk)r"rOs  r#�226initialize�IOLoop.initializeis������ �r'�all_fdsc��[5e)aCloses the `IOLoop`, freeing any resources used.227 228If ``all_fds`` is true, all file descriptors registered on the229IOLoop will be closed (not just the ones created by the230`IOLoop` itself).231 232Many applications will only use a single `IOLoop` that runs for the233entire lifetime of the process.  In that case closing the `IOLoop`234is not necessary since everything will be cleaned up when the235process exits.  `IOLoop.close` is provided mainly for scenarios236such as unit tests, which create and destroy a large number of237``IOLoops``.238 239An `IOLoop` must be completely stopped before it can be closed.  This240means that `IOLoop.stop()` must be called *and* `IOLoop.start()` must241be allowed to return before attempting to call `IOLoop.close()`.242Therefore the call to `close` will usually appear just after243the call to `start` rather than near the call to `stop`.244 245.. versionchanged:: 3.1246   If the `IOLoop` implementation supports non-integer objects247   for "file descriptors", those objects will have their248   ``close`` method when ``all_fds`` is true.249rn)r"r�s  r#r)�IOLoop.closems
��2"�#�#r'�fd�handler�eventsc��grr �r"r�r�r�s    r#�add_handler�IOLoop.add_handler����	
r'c��grr r�s    r#r�r��r�r').Nc��[5e)a�Registers the given handler to receive the given events for ``fd``.250 251The ``fd`` argument may either be an integer file descriptor or252a file-like object with a ``fileno()`` and ``close()`` method.253 254The ``events`` argument is a bitwise or of the constants255``IOLoop.READ``, ``IOLoop.WRITE``, and ``IOLoop.ERROR``.256 257When an event occurs, ``handler(fd, events)`` will be run.258 259.. versionchanged:: 4.0260   Added the ability to pass file-like objects in addition to261   raw file descriptors.262rnr�s    r#r�r��s
��""�#�#r'c��[5e)z�Changes the events we listen for ``fd``.263 264.. versionchanged:: 4.0265   Added the ability to pass file-like objects in addition to266   raw file descriptors.267rn)r"r�r�s   r#�update_handler�IOLoop.update_handler��
��"�#�#r'c��[5e)z�Stop listening for events on ``fd``.268 269.. versionchanged:: 4.0270   Added the ability to pass file-like objects in addition to271   raw file descriptors.272rn�r"r�s  r#�remove_handler�IOLoop.remove_handler�r�r'c��[5e)z�Starts the I/O loop.273 274The loop will run until one of the callbacks calls `stop()`, which275will make the loop stop after the current event iteration completes.276rnr!s r#�start�IOLoop.start�s
��"�#�#r'c��[5e)aYStop the I/O loop.277 278If the event loop is not currently running, the next call to `start()`279will return immediately.280 281Note that even after `stop` has been called, the `IOLoop` is not282completely stopped until `IOLoop.start` has also returned.283Some work that was scheduled before the call to `stop` may still284be run before the `IOLoop` shuts down.285rnr!s r#�stop�IOLoop.stop�s
��"�#�#r'�func�timeoutc�0^^^�[R(a[S[[[286S.5nSSS.mSUUU4SjjnTR
U5 Ub,SUU4SjjnTRTR5U-U5nTR5 UbTRW5 TSceTSR5(dTSR5(d#TS(a[S	U-5e[S2875eTSR5$)a�Starts the `IOLoop`, runs the given function, and stops the loop.288 289The function must return either an awaitable object or290``None``. If the function returns an awaitable object, the291`IOLoop` will run until the awaitable is resolved (and292`run_sync()` will return the awaitable's result). If it raises293an exception, the `IOLoop` will stop and the exception will be294re-raised to the caller.295 296The keyword-only argument ``timeout`` may be used to set297a maximum duration for the function.  If the timeout expires,298a `asyncio.TimeoutError` is raised.299 300This method is useful to allow asynchronous calls in a301``main()`` function::302 303    async def main():304        # do stuff...305 306    if __name__ == '__main__':307        IOLoop.current().run_sync(main)308 309.. versionchanged:: 4.3310   Returning a non-``None``, non-awaitable value is now an error.311 312.. versionchanged:: 5.0313   If a timeout occurs, the ``func`` coroutine will be cancelled.314 315.. versionchanged:: 6.2316   ``tornado.util.TimeoutError`` is now an alias to ``asyncio.TimeoutError``.317�318FutureCell)�future�timeout_calledNFc�d>�T"5nUbSSKJn U"U5n[U5(aUTS'O![5nUTS'UR	U5 TSceTRTSU4Sj5 g![319a1 [5nUTS'[
U[R"55 N\f=f)Nr)�convert_yieldedr�c�$>�TR5$r)r�)r�r"s �r#�<lambda>�.IOLoop.run_sync.<locals>.run.<locals>.<lambda>s���$�)�)�+r')320�tornado.genr�rr�321set_result�	Exceptionr�sys�exc_info�322add_future)�resultr��futr��future_cellr"s   ���r#�run�IOLoop.run_sync.<locals>.run�s����
+�����%�;�,�V�4�F��V�$�$�,2�K��)� �(�C�,/�K��)��N�N�6�*��x�(�4�4�4��O�O�K��1�3M�N���
9��h��(+��H�%�#�C�����8�
9�s�A4�48B/�.B/c�r>�STS'TSceTSR5(dTR5 gg)NTr�r�)�cancelr�)r�r"s��r#�timeout_callback�)IOLoop.run_sync.<locals>.timeout_callbacksC���04��,�-�323#�8�,�8�8�8�"�8�,�3�3�5�5��I�I�K�6r'r�r�z$Operation timed out after %s secondsz+Event loop stopped before Future completed.r+)�typing�
TYPE_CHECKINGrrr�bool�add_callback�add_timeout�timer��remove_timeout�	cancelled�donerrDr�)r"r�r�r�r�r��timeout_handler�s``     @r#�run_sync�IOLoop.run_sync�s���@���"���&�)9�T�R��J�"&��?��	O�	O�*	
���#����	
 �	
 �"�-�-�d�i�i�k�G�.C�EU�V�N��324�325��������/��8�$�0�0�0��x� �*�*�,�,�K��4I�4N�4N�4P�4P��+�,�"�#I�G�#S�T�T�#�#P�Q�Q��8�$�+�+�-�-r'c�,�[R"5$)aOReturns the current time according to the `IOLoop`'s clock.326 327The return value is a floating-point number relative to an328unspecified time in the past.329 330Historically, the IOLoop could be customized to use e.g.331`time.monotonic` instead of `time.time`, but this is not332currently supported and so this method is equivalent to333`time.time`.334 335)r�r!s r#r��IOLoop.time%s���y�y�{�r'�deadline�callback�argsc�2�[U[R5(aUR"X/UQ70UD6$[U[R3365(a6UR"UR
5UR5-U/UQ70UD6$[SU-5e)aRuns the ``callback`` at the time ``deadline`` from the I/O loop.337 338Returns an opaque handle that may be passed to339`remove_timeout` to cancel.340 341``deadline`` may be a number denoting a time (on the same342scale as `IOLoop.time`, normally `time.time`), or a343`datetime.timedelta` object for a deadline relative to the344current time.  Since Tornado 4.0, `call_later` is a more345convenient alternative for the relative case since it does not346require a timedelta object.347 348Note that it is not safe to call `add_timeout` from other threads.349Instead, you must use `add_callback` to transfer control to the350`IOLoop`'s thread, and then call `add_timeout` from there.351 352Subclasses of IOLoop must implement either `add_timeout` or353`call_at`; the default implementations of each will call354the other.  `call_at` is usually easier to implement, but355subclasses that wish to maintain compatibility with Tornado356versions prior to 4.0 must use `add_timeout` instead.357 358.. versionchanged:: 4.0359   Now passes through ``*args`` and ``**kwargs`` to the callback.360�Unsupported deadline %r)	r@�numbers�Real�call_at�datetime�	timedeltar��
total_seconds�	TypeError)r"r�r�r�r<s     r#r��IOLoop.add_timeout3s���@�h����-�-��<�<��D�T�D�V�D�D�
��(�"4�"4�
5�
5��<�<��	�	��h�4�4�6�6���CG��KQ��
��5��@�A�Ar'�delayc�R�UR"UR5U-U/UQ70UD6$)aRRuns the ``callback`` after ``delay`` seconds have passed.361 362Returns an opaque handle that may be passed to `remove_timeout`363to cancel.  Note that unlike the `asyncio` method of the same364name, the returned object does not have a ``cancel()`` method.365 366See `add_timeout` for comments on thread-safety and subclassing.367 368.. versionadded:: 4.0369)r�r�)r"r�r�r�r<s     r#�370call_later�IOLoop.call_later\s*���|�|�D�I�I�K�%�/��K�D�K�F�K�Kr'�whenc�.�UR"X/UQ70UD6$)a�Runs the ``callback`` at the absolute time designated by ``when``.371 372``when`` must be a number using the same reference point as373`IOLoop.time`.374 375Returns an opaque handle that may be passed to `remove_timeout`376to cancel.  Note that unlike the `asyncio` method of the same377name, the returned object does not have a ``cancel()`` method.378 379See `add_timeout` for comments on thread-safety and subclassing.380 381.. versionadded:: 4.0382)r�)r"r�r�r�r<s     r#r��IOLoop.call_atks�� ����@��@��@�@r'c��[5e)z�Cancels a pending timeout.383 384The argument is a handle as returned by `add_timeout`.  It is385safe to call `remove_timeout` even if the callback has already386been run.387rn)r"r�s  r#r��IOLoop.remove_timeout}r�r'c��[5e)a�Calls the given callback on the next I/O loop iteration.388 389It is safe to call this method from any thread at any time,390except from a signal handler.  Note that this is the **only**391method in `IOLoop` that makes this thread-safety guarantee; all392other interaction with the `IOLoop` must be done from that393`IOLoop`'s thread.  `add_callback()` may be used to transfer394control from other threads to the `IOLoop`'s thread.395rn�r"r�r�r<s    r#r��IOLoop.add_callback�s
��"�#�#r'c��[5e)aPCalls the given callback on the next I/O loop iteration.396 397Intended to be afe for use from a Python signal handler; should not be398used otherwise.399 400.. deprecated:: 6.4401   Use ``asyncio.AbstractEventLoop.add_signal_handler`` instead.402   This method is suspected to have been broken since Tornado 5.0 and403   will be removed in version 7.0.404rnr�s    r#�add_callback_from_signal�IOLoop.add_callback_from_signal�s
��"�#�#r'c�0�UR"U/UQ70UD6 g)z�Calls the given callback on the next IOLoop iteration.405 406As of Tornado 6.0, this method is equivalent to `add_callback`.407 408.. versionadded:: 4.0409N�r�r�s    r#�spawn_callback�IOLoop.spawn_callback�s��	
���(�4�T�4�V�4r'r�z0Union[Future[_T], concurrent.futures.Future[_T]]z410Future[_T]c�^^�[U[5(aURUU4Sj5 g[U5(de[	UUU4Sj5 g)a	Schedules a callback on the ``IOLoop`` when the given411`.Future` is finished.412 413The callback is invoked with one argument, the414`.Future`.415 416This method only accepts `.Future` objects and not other417awaitables (unlike most of Tornado where the two are418interchangeable).419c�P>�TR[R"TU55$r)�
_run_callback�	functools�partial��fr�r"s ��r#r��#IOLoop.add_future.<locals>.<lambda>�s���$�,�,�Y�->�->�x��-K�Lr'c�(>�TRTU5$rr�r�s ��r#r�r��s���t�7H�7H��ST�7Ur'N)r@r�add_done_callbackrr)r"r�r�s` `r#r��IOLoop.add_future�sE����f�f�%�%�
�$�$�L�
��V�$�$�$�$�
%�V�-U�Vr'�executor.c�^�UcM[US5(d0SSKJn [RRU"5S-S9UlURnUR"U/UQ76n[5mURUU4Sj5 T$)z�Runs a function in a ``concurrent.futures.Executor``. If420``executor`` is ``None``, the IO loop's default executor will be used.421 422Use `functools.partial` to pass keyword arguments to ``func``.423 424.. versionadded:: 5.0425�	_executorr)�	cpu_count�)�max_workersc�>�[UT5$r)r)r��t_futures �r#r��(IOLoop.run_in_executor.<locals>.<lambda>�s���L��H�,Er')426�hasattr�tornado.processr��427concurrent�futures�ThreadPoolExecutorr��submitrr�)r"r�r�r�r��c_futurer�s      @r#�run_in_executor�IOLoop.run_in_executor�s}������4��-�-�5�!+�!3�!3�!F�!F�!*��q��"G�"����~�~�H��?�?�4�/�$�/���8������"E�F��r'c��Xlg)zVSets the default executor to use with :meth:`run_in_executor`.428 429.. versionadded:: 5.0430N�r�)r"r�s  r#�set_default_executor�IOLoop.set_default_executor�s	��431"�r'c�$�U"5nUb4SSKJn URU5nURX R5 gg!UR432a gf=f![Ra g[a [R"SUSS9 gf=f)zhRuns a callback with error handling.433 434.. versionchanged:: 6.0435 436   CancelledErrors are no longer logged.437Nr)�gen�Exception in callback %rT�r�)�tornador	r�r��_discard_future_result�
BadYieldErrorr]�CancelledErrorr�r	�error)r"r��retr	s    r#r��IOLoop._run_callback�s���	O��*�C���'�F��-�-�c�2�C��O�O�C�)D�)D�E����(�(���	���%�%�	���	O��M�M�4�h��N�	O�s9�A�A�A�A�A�A�A�B�-B�Bc�$�UR5 g)z;Avoid unhandled-exception warnings from spawned coroutines.N)r�)r"r�s  r#r
�IOLoop._discard_future_results���
�
�r'c�V�[U[5(aX4$UR5U4$r)r@r0r$r�s  r#�split_fd�IOLoop.split_fds(��$�b�#����6�M��y�y�{�B��r'c��[U[5(a[R"U5 gUR5 g![a gf=fr)r@r0�osr)�OSErrorr�s  r#�close_fd�IOLoop.close_fd&s:��	��"�c�"�"���������438���	��	�s�+?�?�439A�Ar�c�:�URRU5 gr)�_pending_tasks�add�r"r�s  r#�_register_task�IOLoop._register_task:s��������"r'c�:�URRU5 gr)r�discardr s  r#�_unregister_task�IOLoop._unregister_task=s�����#�#�A�&r'r)rr6r+)T)Fr)Lr,r-r.r/�__doc__�NONE�READ�WRITE�ERROR�dictra�setr�classmethodrrF�staticmethodrLrPrTr��overloadrKr�rrOrkrSrrrurr440r{rr�r)r0rr�r3r
rr�r�r�r��floatr�r�r�r��objectr�r�r�r�r�r�r�r�r�r��Executorr2rrr�rr
rrrr!r%r1�
__classcell__)rHs@r#r6r6HsJ���K�\
�D��D��E��E��&���U�N��	*�9�	*�EH�	*�	
�	*��	*�� �� �*��
��
��_�_��
���
��_�_��
�$�
�(�8�*<�
���
��*�$�*�(�8�*<�*��*�X�6$�� �� � �&��&�441
���$�|�"4������T�,�%7����442!�t�!�t�!�$�T�$�d�$�6�_�_�
��
� (�#�s��T�)9� :�
�DG�
�	
�
��
�443�_�_�
��
�'��S�	�4��8�
�BE�
�	
�
��
�444$���[�(�)�$�4<�Y�4G�$�QT�$�	
�$�&$��s�K�'7�!8�$�#�$�$�$�$��s�K�'7�!8�$�T�$�$�$�U.�X�U.����U.�3�U.�n�e��'B���x�1�1�1�2�'B��'B��	'B�445�'B�446�
'B�R
L��
L�&.�
L�7:�
L�FI�
L�	�
L�A��A�%-�A�69�A�EH�A�	�A�$$�f�$��$�447$�X�448$�c�449$�S�450$�T�451$�
$� �
$�),�
$�8;�
$�	
�
$�5�x�5��5�s�5�t�5�W�B�W��L�>�4�/�0�W�452�	W�B��:�-�-�6�6�7���s�B�w����	�453454��8"�Z�-?�-?�-H�-H�"�T�"�O�h�r�3�w�&7�O�D�O�<�V�������[�(�)��	�s�E�#�{�*�+�+�	,��,�5��k�!1�2��t��(#��#�4�#�'�&�'�T�'�'r'r6c�h�\rSrSrSr/SQrS\S\/S4S\SS4S	jr	S455SS\4564SjrS457SS\4584SjrS
r
g)�_TimeoutiAz2An IOLoop timeout, a UNIX timestamp and a callback)r�r��	tdeadliner�r�N�io_looprc��[U[R5(d[SU-5eXlX lU[
UR54Ulg)Nr�)	r@r�r�r�r�r��next�_timeout_counterr7)r"r�r�r8s    r#�__init__�_Timeout.__init__GsJ���(�G�L�L�1�1��5��@�A�A� �
� �
����)�)�*�459��r'�otherc�4�URUR:$r�r7�r"r>s  r#�__lt__�_Timeout.__lt__Ws���~�~����/�/r'c�4�URUR:*$rr@rAs  r#�__le__�_Timeout.__le__Zs���~�~����0�0r')r�r�r7)r,r-r.r/r'�	__slots__r1rr6r<r�rBrEr1r r'r#r6r6As`��<�6�I�460461��462463�)1�"�d�(�);�464465�FL�466467�	
�468469� 0�J�0�4�0�1�J�1�4�1r'r6c	��\rSrSrSrSS\/\\4S\\	R\4S\SS4SjjrSS	jr
SS470jrS\4SjrSSjrSS
jrS\SS4SjrSrg)�PeriodicCallbacki^aSchedules the given callback to be called periodically.471 472The callback is called every ``callback_time`` milliseconds when473``callback_time`` is a float. Note that the timeout is given in474milliseconds, while most other time-related functions in Tornado use475seconds. ``callback_time`` may alternatively be given as a476`datetime.timedelta` object.477 478If ``jitter`` is specified, each callback time will be randomly selected479within a window of ``jitter * callback_time`` milliseconds.480Jitter can be used to reduce alignment of events with similar periods.481A jitter of 0.1 means allowing a 10% variation in callback time.482The window is centered on ``callback_time`` so the total number of calls483within a given interval should not be significantly affected by adding484jitter.485 486If the callback runs for longer than ``callback_time`` milliseconds,487subsequent invocations will be skipped to get back on schedule.488 489`start` must be called after the `PeriodicCallback` is created.490 491.. versionchanged:: 5.0492   The ``io_loop`` argument (deprecated since version 4.1) has been removed.493 494.. versionchanged:: 5.1495   The ``jitter`` argument is added.496 497.. versionchanged:: 6.2498   If the ``callback`` argument is a coroutine, and a callback runs for499   longer than ``callback_time``, subsequent invocations will be skipped.500   Previously this was only true for regular functions, not coroutines,501   which were "fire-and-forget" for `PeriodicCallback`.502 503   The ``callback_time`` argument now accepts `datetime.timedelta` objects,504   in addition to the previous numeric milliseconds.505r��
callback_time�jitterrNc���Xl[U[R5(aU[R"SS9-UlOUS::a[S5eX lX0lSUlSUlg)Nr8)�millisecondsrz4Periodic callback must have a positive callback_timeF)	r�r@r�r�rJ�506ValueErrorrK�_running�_timeout)r"r�rJrKs    r#r<�PeriodicCallback.__init__�sb��!�
��m�X�%7�%7�8�8�!.��1C�1C�QR�1S�!S�D����!� �!W�X�X�!.������
���
r'c��[R5UlSUlURR	5UlUR
5 g)zStarts the timer.TN)r6rKr8rOr��
_next_timeout�_schedule_nextr!s r#r��PeriodicCallback.start�s:��507�~�~�'�����
�!�\�\�.�.�0������r'c��SUlURb-URRUR5 SUlgg)zStops the timer.FN)rOrPr8r�r!s r#r��PeriodicCallback.stop�s5����
��=�=�$��L�L�'�'��
�
�6� �D�M�%r'c��UR$)zVReturns ``True`` if this `.PeriodicCallback` has been started.508 509.. versionadded:: 4.1510)rOr!s r#�511is_running�PeriodicCallback.is_running�s��512�}�}�r'c��:# �UR(dgUR5nUb[U5(a513UIShv�N UR
5 gN![a# [R514"SURSS9 N?f=f!UR
5 f=f7f)Nr515Tr)rOr�rr�r	rrT)r"�vals  r#�_run�PeriodicCallback._run�s|����}�}��	"��-�-�/�C���;�s�#3�#3��	�	�
���!�	���	T��M�M�4�d�m�m�d�S�	T��
���!�sD�B�(A�A�A�B�A�*B�B�B�B�B�Bc���UR(a_URURR55 URR	UR516UR5Ulggr)rO�_update_nextr8r�r�rSr]rPr!s r#rT�PeriodicCallback._schedule_next�sK���=�=����d�l�l�/�/�1�2� �L�L�4�4�T�5G�5G����S�D�M�r'�current_timec�b�URS-nUR(a+USUR[R"5S-517---nURU::a?U=R[R518"XR-519U-5S-U--
slgU=RU-
slg)Ng@�@r8g�?)rJrK�randomrS�math�floor)r"rb�callback_time_secs   r#r`�PeriodicCallback._update_next�s��� �.�.��7���;�;���d�k�k�V�]�]�_�s�5J�&K�!L�L������-�520
����521�522�L�+=�+=�=�AR�R�S�VW�W�!�#"�
"��$
���"3�3�r')rSrOrPr�rJr8rK)rr+)r,r-r.r/r'rrrr
r�r�r1r<r�r�r�rYr]rTr`r1r r'r#rIrI^s���#�R�	��2�x�	�2�2�3���X�/�/��6�7���	�523524��"�!��D��525"�T�5264��4�4�4r'rI)2r'r]�concurrent.futuresr�r�r�r�rr�r�rerdrh�inspectr�tornado.concurrentrrrrr�tornado.logr	�tornado.utilr527rrr�r
rrrrrrrr�rrrr�typing_extensionsrr2rr2r3r6r6rIr r'r#�<module>ros��� ������	�528���
����� �B�B�
�R�R�R�	���1�1�*��H�
�(�
�
�T�]���T��%��v'�\�v'�r1�1�:|4�|4r'
codekingpro/portable-devtools · Team Ai