def _reloader_stat_loop(extra_files=None, interval=1):
 from itertools import chain
 mtimes = {}
 while 1:
  for filename in chain(_iter_module_files(), (extra_files or ())):
   try:
    mtime = os.stat(filename).st_mtime
   except OSError:
    continue
   old_time = mtimes.get(filename)
   if (old_time is None):
    mtimes[filename] = mtime
    continue
   elif (mtime > old_time):
    _log('info', (' * Detected change in %r, reloading' % filename))
    sys.exit(3)
  time.sleep(interval)

def _reloader_stat_loop ( extra_files = None , interval = 1 ) : from itertools import chain mtimes = { } while 1 : for filename in chain ( _iter_module_files ( ) , ( extra_files or ( ) ) ) : try : mtime = os . stat ( filename ) . st_mtime except OSError : continue old_time = mtimes . get ( filename ) if ( old_time is None ) : mtimes [ filename ] = mtime continue elif ( mtime > old_time ) : _log ( 'info' , ( ' * Detected change in %r, reloading' % filename ) ) sys . exit ( 3 ) time . sleep ( interval )
when this function is run from the main thread .