Ñò ô†³Kc @ sá d Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k l Z d d „ Z d e f d „ ƒ YZ e i i d ƒ oD y d d k l Z Wn e j o qË Xd e f d „ ƒ YZ n e i Z e i Z d S( sÊ A file monitor and server restarter. Use this like: ..code-block:: Python import reloader reloader.install() Then make sure your server is installed with a shell script like:: err=3 while test "$err" -eq 3 ; do python server.py err="$?" done or is run from this .bat file (if you use Windows):: @echo off :repeat python server.py if %errorlevel% == 3 goto repeat or run a monitoring process in Python (``paster serve --reload`` does this). Use the ``watch_file(filename)`` function to cause a reload/restart for other other non-Python files (e.g., configuration files). If you have a dynamic set of files that grows over time you can use something like:: def watch_config_files(): return CONFIG_FILE_CACHE.keys() paste.reloader.add_file_callback(watch_config_files) Then every time the reloader polls files it will call ``watch_config_files`` and check all the filenames it returns. iÿÿÿÿN( t classinstancemethodi c C s? t d | ƒ } t i d | i ƒ } | i t ƒ | i ƒ d S( s, Install the reloading monitor. On some platforms server threads may not terminate when the main thread does, causing ports to remain open/locked. The ``raise_keyboard_interrupt`` option creates a unignorable signal which causes the whole application to shut-down (rudely). t poll_intervalt targetN( t Monitort threadingt Threadt periodic_reloadt setDaemont Truet start( R t mont t( ( s2 /usr/lib/python2.6/site-packages/paste/reloader.pyt install2 s R c B s_ e Z g Z g Z g Z d „ Z d „ Z d „ Z d „ Z e e ƒ Z d „ Z e e ƒ Z RS( c C sS h | _ t | _ | | _ t | i ƒ | _ | i i | ƒ t | i ƒ | _ d S( N( t module_mtimesR t keep_runningR t listt global_extra_filest extra_filest instancest appendt global_file_callbackst file_callbacks( t selfR ( ( s2 /usr/lib/python2.6/site-packages/paste/reloader.pyt __init__F s c C sB x; t o3 | i ƒ p t i d ƒ Pn t i | i ƒ q Wd S( Ni ( R t check_reloadt ost _exitt timet sleepR ( R ( ( s2 /usr/lib/python2.6/site-packages/paste/reloader.pyR N s c C s t | i ƒ } xJ | i D]? } y | i | ƒ ƒ Wq t i d | IJt i ƒ q Xq Wxc t i i ƒ D]R } y | i } Wn t t f j o } ql n X| d j o | i | ƒ ql ql WxD| D]<} y- t i | ƒ } | o | i } n d } Wn t t f j o qÉ n X| i d ƒ o: t i i | d ƒ o# t t i | d ƒ i | ƒ } nS | i d ƒ oB t i i | d d ƒ o' t t i | d d ƒ i | ƒ } n | i i | ƒ p | | i |