Ë
    êmxiP3  ã                   ól  — U d Z ddlZddlZedk(  r8ej                  d   ej                  j                  e«      k(  rej                  d= ddlZddlZ	ddlZddl
Z
ddlZddlZddlZddlZddlZddlmZ ddlmZ ddlmZ 	 ddlZddlmZmZmZmZmZ ej8                  dk7  Z e«       Zg Z d	a! ejD                  «       Z#d
e$d<   d	a%da&eee'      e$d<   da(dde)ddfd„Z*dd„Z+de'ddfd„Z,deg df   ddfd„Z-dee'e.f   ddfd„Z/dee'e.f   de'ddfd„Z0dd„Z1dZ2dd„Z3edk(  r e3«        yy# e$ r dZY Œ®w xY w)a7  Automatically 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)ÚCallableÚDictÚOptionalÚListÚUnionÚwin32Fz.weakref.WeakKeyDictionary[ioloop.IOLoop, bool]Ú	_io_loopsÚ_original_argvÚ
check_timeÚreturnc                 ó6  — t         j                  j                  «       }|t        v rydt        |<   t	        t        «      dkD  rt        j                  d«       i }t        j                  t        |«      }t        j                  || «      }|j                  «        y)zœBegins watching source files for changes.

    .. versionchanged:: 5.0
       The ``io_loop`` argument (deprecated since version 4.1) has been removed.
    NTé   z=tornado.autoreload started more than once in the same process)r   ÚIOLoopÚcurrentr   Úlenr   ÚwarningÚ	functoolsÚpartialÚ_reload_on_updateÚPeriodicCallbackÚstart)r   Úio_loopÚmodify_timesÚcallbackÚ	schedulers        úI/home/htdocs/ttos/venv/lib/python3.12/site-packages/tornado/autoreload.pyr   r   r   sx   € ô �m‰m×#Ñ#Ó%€GØ”)ÑØØ„IˆgÑÜ
Œ9ƒ~˜ÒÜ�‰ÐWÔXØ%'€LÜ× Ñ Ô!2°LÓA€HÜ×'Ñ'¨°*Ó=€IØ‡O�OÕó    c                  óv   — t        j                  «       } | j                  t        «       | j                  «        y)zùWait 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)r   r   Úadd_callbackr   )r   s    r    Úwaitr$   „   s&   € ô �m‰m‹o€GØ×ÑœÔØ‡M�M…Or!   Úfilenamec                 ó.   — t         j                  | «       y)zTAdd a file to the watch list.

    All imported modules are watched by default.
    N)Ú_watched_filesÚadd)r%   s    r    Úwatchr)   �   s   € ô
 ×Ñ�xÕ r!   Úfnc                 ó.   — t         j                  | «       y)a  Add 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_hooksÚappend)r*   s    r    Úadd_reload_hookr.   ˜   s   € ô ×Ñ˜Õr!   r   c                 ó~  — t         ry t        j                  «       �y t        t        j
                  j                  «       «      D ]`  }t        |t        j                  «      sŒt        |dd «      }|sŒ.|j                  d«      s|j                  d«      r|d d }t        | |«       Œb t        D ]  }t        | |«       Œ y )NÚ__file__z.pycz.pyoéÿÿÿÿ)Ú_reload_attemptedr   Útask_idÚlistÚsysÚmodulesÚvaluesÚ
isinstanceÚtypesÚ
ModuleTypeÚgetattrÚendswithÚ_check_filer'   )r   ÚmoduleÚpaths      r    r   r   ¢   s«   € ÝàÜ‡�ÓÐ$ð 	Ü”s—{‘{×)Ñ)Ó+Ó,ò (ˆô
 ˜&¤%×"2Ñ"2Ô3ØÜ�v˜z¨4Ó0ˆÙØØ�=‰=˜Ô  D§M¡M°&Ô$9Ø˜˜�9ˆDÜ�L $Õ'ð(ô ò (ˆÜ�L $Õ'ñ(r!   r?   c                 óÈ   — 	 t        j                  |«      j                  }|| vr|| |<   y | |   |k7  r!t	        j
                  d|«       t        «        y y # t        $ r Y y w xY w)Nz%s modified; restarting server)ÚosÚstatÚst_mtimeÚ	Exceptionr   ÚinfoÚ_reload)r   r?   Úmodifieds      r    r=   r=   ¼   sk   € ðÜ—7‘7˜4“=×)Ñ)ˆð �<ÑØ%ˆ�TÑØØ�DÑ˜XÒ%Ü�‰Ð5°tÔ<Ü�	ð &øô ò Ùðús   ‚A Á	A!Á A!c                  ój  — da t        D ]	  }  | «        Œ t        j                  dk7  r%t	        j
                  t        j                  dd«       t        rt        €J ‚t        }t        }n.t        t        j                  d   dd «      }t        j                  }|r#|j                  dk7  rd|j                  g|dd  z   }t        s=t        j                   t        j"                  g|z   «       t%        j&                  d«       y t%        j(                  t        j"                  t        j"                  g|z   «       y )NTr   r   r   Ú__spec__ú-mr   )r2   r,   r5   ÚplatformÚsignalÚ	setitimerÚITIMER_REALÚ_autoreload_is_mainr   Ú_original_specr;   r6   ÚargvÚnameÚ
_has_execvÚ
subprocessÚPopenÚ
executablerA   Ú_exitÚexecv)r*   ÚspecrQ   s      r    rF   rF   É   sì   € àÐÜò ˆÙ
�ðä
‡|�|�wÒô 	×Ñœ×+Ñ+¨Q°Ô2õ
 ÜÐ)Ð)Ð)ÜˆÜ‰ä”s—{‘{ :Ñ.°
¸DÓAˆÜ�x‰xˆÙ�—	‘	˜ZÒ'ð �d—i‘iÐ  4¨¨ 8Ñ+ˆåÜ×Ñœ#Ÿ.™.Ð)¨DÑ0Ô1Ü
�‰��ä
�‰”—‘¤#§.¡.Ð!1°DÑ!8Õ9r!   zv
  python -m tornado.autoreload -m module.to.run [args...]
  python -m tornado.autoreload path/to/script.py [args...]
c                  ó@  — ddl } ddl}dx|j                  _        at        j
                  }|x|j                  _        at        t        j                  d   dd«      }|x|j                  _	        a	| j                  dt        d¬«      }|j                  «        |j                  d	d
d
d¬«       |j                  ddd¬«       |j                  «       \  }}|j                  €F|s0t!        dt        j"                  ¬«       t	        j$                  d«       |d   }|dd t        _        n"d}t        j
                  d   g|z   t        _        d}	 ddl}	|j                  �|	j)                  |j                  dd¬«       n|€J ‚|	j+                  |d¬«       d}t-        j.                  d«       |t        _        |j                  �l|j                  €J ‚tG        jH                  |j                  «      }|�=tA        |tJ        jL                  jN                  «      rt?        |jQ                  «       «       |jR                  r|sytU        «        y# t0        $ r6}
|
j2                  }t-        j.                  d|
j2                  «       Y d}
~
Œ×d}
~
wt4        $ r’}
t-        j6                  dd¬«       t9        j:                  t	        j<                  «       d   «      D ]  \  }}}}t?        |«       Œ tA        |
tB        «      r!|
jD                  �t?        |
jD                  «       Y d}
~
�Œpd}
~
ww xY w)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`.
    r   NTr   rI   zpython -m tornado.autoreloadz3Either -m or a path must be specified, but not both)ÚprogÚusageÚepilogrJ   r>   zmodule to run)ÚdestÚmetavarÚhelpz--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)rd   zScript exited normallyzScript exited with status %sz%Script exited with uncaught exception)Úexc_infoé   )+ÚoptparseÚtornado.autoreloadÚ
autoreloadrO   r5   rQ   r   r;   r6   rP   ÚOptionParserÚ_USAGEÚdisable_interspersed_argsÚ
add_optionÚ
parse_argsr>   ÚprintÚstderrÚexitÚrunpyÚ
run_moduleÚrun_pathr   rE   Ú
SystemExitÚcoderD   r   Ú	tracebackÚ
extract_tbrf   r)   r8   ÚSyntaxErrorr%   ÚpkgutilÚ
get_loaderÚ	importlibÚabcÚ
FileLoaderÚget_filenameÚuntil_successr$   )rh   ÚtornadoÚoriginal_argvÚoriginal_specÚparserÚoptsÚrestr?   Úexit_statusrs   Úer%   ÚlinenorR   ÚlineÚloaders                   r    Úmainr�   ö   s¬  € ó* Ûð DHÐG€G×ÑÔ*Ð-@Ü—H‘H€MØ9FÐF€G×ÑÔ%¨ÜœCŸK™K¨
Ñ3°ZÀÓF€MØ9FÐF€G×ÑÔ%¨à×"Ñ"Ø+ÜØDð #ó €Fð
 ×$Ñ$Ô&Ø
×Ñ�d °8À/ÐÔRØ
×ÑØØØRð ô ð
 ×"Ñ"Ó$�J€Dˆ$Ø‡{�{ÐÙÜÐ9ÄÇ
Á
ÕKÜ�H‰H�QŒKØ�A‰wˆØ™�7Œ�àˆÜ—H‘H˜Q‘K�= 4Ñ'ŒŒð *+€Kð/Ûà�;‰;Ð"Ø×Ñ˜TŸ[™[°:ÈÐÕNàÐ#Ð#Ð#Ø�N‰N˜4¨*ˆNÔ5ð& ˆÜ�‰Ð-Ô.à„C„Hà‡{�{ÐØ�{‰{Ð&Ð&Ð&ô ×#Ñ# D§K¡KÓ0ˆØÐ¤*¨V´Y·]±]×5MÑ5MÔ"NÜ�&×%Ñ%Ó'Ô(Ø×Ò¡+ØÜ…FøôA ò =Ø—f‘fˆÜ�‰Ð3°Q·V±V×<Ñ<ûÜò "Ü�‰Ð?È$ÕOô
 -6×,@Ñ,@ÄÇÁÃÐPQÑARÓ,Sò 	Ñ(ˆH�f˜d DÜ�(�Oð	ä�aœÔ%ð �z‰zÐ%Ü�a—j‘jÔ!ÿùð"ús&   ÅAI É	LÉ,I?É?LÊBLÌL)iô  )r   N)4Ú__doc__rA   r5   Ú__name__r?   Údirnamer0   r   Úimportlib.abcr}   r{   rx   r9   rT   Úweakrefr‚   r   Útornado.logr   r   rL   ÚImportErrorÚtypingr   r   r	   r
   r   rK   rS   Úsetr'   r,   r2   ÚWeakKeyDictionaryr   Ú__annotations__rO   r   ÚstrrP   Úintr   r$   r)   r.   Úfloatr   r=   rF   rl   r�   © r!   r    ú<module>r�      sž  ðò ó< 
Û 
ð( ˆzÒð ‡x�x��{�b—g‘g—o‘o hÓ/Ò/Ø�H‰H�QˆKã Û Û 	Û Û 
Û Û Û Û å Ý Ý ðÛ÷ 9Õ 8ð
 �\‰\˜WÑ$€
á“€Ø€ØÐ à€G×ÑÓð 
Ð;ó ð Ð Ø&*€�˜˜c™Ñ#Ó *Ø€ñ�cð  Dó ó$	ð!�Cð !˜Dó !ð˜  T Ñ*ð ¨tó ð( D¨¨e¨Ñ$4ð (¸ó (ð4
˜d 3¨ :Ñ.ð 
°cð 
¸dó 
ó$:ðN
€óbðJ ˆzÒñ 	…Fð øð} ò Ø‚Fðús   Â D) Ä)D3Ä2D3