possible bug in cherrypy.lib.autoreloader

infidel saint.infidel at gmail.com
Thu Oct 20 00:09:17 CEST 2005

I may have found the source of my infinite loop when importing kid
modules from my cherrypy server.  Here is some code from the
autoreloader module of cherrypy:

def reloader_thread():
    mtimes = {}

    def fileattr(m):
        return getattr(m, "__file__", None)

    while RUN_RELOADER:
        for filename in map(fileattr, sys.modules.values()) +
            if filename:
                if filename.endswith(".pyc"):
                    filename = filename[:-1]
                    mtime = os.stat(filename).st_mtime
                except OSError:
                    sys.exit(3) # force reload
                if filename not in mtimes:
                    mtimes[filename] = mtime
                if mtime > mtimes[filename]:
                    sys.exit(3) # force reload

So what happens if one of my modules is a kid template named
'login.kid'?  kid compiles the template to login.pyc, which means the
os.stat call in this function will be passed 'login.py' which does not

More information about the Python-list mailing list