K iP3lUdZddlZddlZedk(r8ejdejj ek(r ejd=ddlZddlZ ddlZddl Z ddlZddl Z ddl Z ddl Z ddlZddlmZddlmZddlmZ ddlZddlmZmZmZmZmZej8dk7ZeZgZ d a!ejDZ#d e$d <d a%da&eee'e$d <da(dd e)ddfdZ*ddZ+de'ddfdZ,degdfddfdZ-dee'e.fddfdZ/dee'e.fde'ddfdZ0ddZ1dZ2ddZ3edk(re3yy#e$rdZYwxYw)a7Automatically restart the server when a source file is modified. Most applications should not access this module directly. Instead, pass the keyword argument ``autoreload=True`` to the `tornado.web.Application` constructor (or ``debug=True``, which enables this setting and several others). This will enable autoreload mode as well as checking for changes to templates and static resources. Note that restarting is a destructive operation and any requests in progress will be aborted when the process restarts. (If you want to disable autoreload while using other debug-mode features, pass both ``debug=True`` and ``autoreload=False``). This module can also be used as a command-line wrapper around scripts such as unit test runners. See the `main` method for details. The command-line wrapper and Application debug modes can be used together. This combination is encouraged as the wrapper catches syntax errors and other import-time failures, while debug mode catches changes once the server has started. This module will not work correctly when `.HTTPServer`'s multi-process mode is used. Reloading loses any Python interpreter command-line arguments (e.g. ``-u``) because it re-executes Python using ``sys.executable`` and ``sys.argv``. Additionally, modifying these variables will cause reloading to behave incorrectly. N__main__)ioloop)gen_log)process)CallableDictOptionalListUnionwin32Fz.weakref.WeakKeyDictionary[ioloop.IOLoop, bool] _io_loops_original_argv check_timereturnc6tjj}|tvrydt|<t tdkDrt j di}tjt|}tj||}|jy)zBegins watching source files for changes. .. versionchanged:: 5.0 The ``io_loop`` argument (deprecated since version 4.1) has been removed. NTz=tornado.autoreload started more than once in the same process) rIOLoopcurrentr lenrwarning functoolspartial_reload_on_updatePeriodicCallbackstart)rio_loop modify_timescallback schedulers X/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tornado/autoreload.pyrrrsx mm##%G)Ig 9~WX%'L  !2LAH''*=I OOcvtj}|jt|jy)zWait for a watched file to change, then restart the process. Intended to be used at the end of scripts like unit test runners, to run the tests again after any source file changes (but see also the command-line interface in `main`) N)rr add_callbackr)rs r waitr$s&mmoG  MMOr!filenamec.tj|y)zTAdd a file to the watch list. All imported modules are watched by default. N)_watched_filesadd)r%s r watchr)s x r!fnc.tj|y)aAdd a function to be called before reloading the process. Note that for open file and socket handles it is generally preferable to set the ``FD_CLOEXEC`` flag (using `fcntl` or `os.set_inheritable`) instead of using a reload hook to close them. N) _reload_hooksappend)r*s r add_reload_hookr.sr!rc~trytjyttj j D]`}t|tjst|dd}|s.|jds|jdr|dd}t||btD]}t||y)N__file__z.pycz.pyo)_reload_attemptedrtask_idlistsysmodulesvalues isinstancetypes ModuleTypegetattrendswith _check_filer')rmodulepaths r rrs$ s{{))+, ( &%"2"23 vz40  == DMM&$99DL$' ((L$'(r!r?c tj|j}||vr|||<y|||k7r!t j d|t yy#t$rYywxYw)Nz%s modified; restarting server)osstatst_mtime Exceptionrinfo_reload)rr?modifieds r r=r=sk774=)) <% TDX% 5t< & sA A! A!cjdatD] }| tjdk7r%t j tj ddtrtJt}t}n.ttjddd}tj}|r#|jdk7rd|jg|ddz}ts=tj tj"g|zt%j&dyt%j(tj"tj"g|zy)NTr rr__spec__-mr)r2r,r5platformsignal setitimer ITIMER_REAL_autoreload_is_mainr_original_specr;r6argvname _has_execv subprocessPopen executablerA_exitexecv)r*specrQs r rFrFs    ||w ++Q2 )))s{{:. DAxx  Z'dii 48+ #..)D01   #..!1D!89r!zv python -m tornado.autoreload -m module.to.run [args...] python -m tornado.autoreload path/to/script.py [args...] c@ddl}ddl}dx|j_atj }|x|j_attjddd}|x|j_ a |jdtd}|j|jd d d d |jd dd|j\}}|jF|s0t!dtj"t j$d|d}|ddt_n"d}tj dg|zt_d} ddl} |j| j)|jddn|J| j+|dd}t-j.d|t_|jl|jJtGjH|j}|=tA|tJjLjNrt?|jQ|jRr|sytUy#t0$r6} | j2}t-j.d| j2Yd} ~ d} ~ wt4$r} t-j6ddt9j:t j<dD]\} } } }t?| tA| tBr!| jDt?| jDYd} ~ pd} ~ wwxYw)a Command-line wrapper to re-run a script whenever its source changes. Scripts may be specified by filename or module name:: python -m tornado.autoreload -m tornado.test.runtests python -m tornado.autoreload tornado/test/runtests.py Running a script with this wrapper is similar to calling `tornado.autoreload.wait` at the end of the script, but this wrapper can catch import-time problems like syntax errors that would otherwise prevent the script from reaching its call to `wait`. rNTrrIzpython -m tornado.autoreloadz3Either -m or a path must be specified, but not both)progusageepilogrJr>z module to run)destmetavarhelpz--until-success store_truezCstop reloading after the program exist successfully (status code 0))actionr`z%Either -m or a path must be specified)filer)run_name alter_sys)rdzScript exited normallyzScript exited with status %sz%Script exited with uncaught exception)exc_info)+optparsetornado.autoreload autoreloadrOr5rQrr;r6rP OptionParser_USAGEdisable_interspersed_args add_option parse_argsr>printstderrexitrunpy run_modulerun_pathrrE SystemExitcoderDr traceback extract_tbrfr)r8 SyntaxErrorr%pkgutil get_loader importlibabc FileLoader get_filename until_successr$)rhtornado original_argv original_specparseroptsrestr? exit_statusrser%linenorRlineloaders r mainrs*DHGG*-@HHM9FFG%CKK 3ZFM9FFG%  " " +D#F  $$& d8/R  R ""$JD$ {{ 9 K HHQKAw7HHQK=4'*+K/ ;; "   T[[:  N# ## NN4*N 5&  -.CH {{{{&&&##DKK0  *VY]]5M5M"N &%%' ( +FA =ff  3QVV<<  "?$O -6,@,@PQAR,S  (HfdD (O  a %zz%ajj! "s& AI L,I?? L BLL)i)rN)4__doc__rAr5__name__r?dirnamer0r importlib.abcr}r{rxr9rTweakrefrr tornado.logrrrL ImportErrortypingrrr r r rKrSsetr'r,r2WeakKeyDictionaryr __annotations__rOrstrrPintrr$r)r.floatrr=rFrlrr!r rs < ( z xx{bggooh// HHQK   98 \\W $  G ;&*c#*cD$ !C!D!T*t(De$4((4 d3:. c d $:N  b J z F} FsD))D32D3