possible bug in cherrypy.lib.autoreloader

infidel saint.infidel at gmail.com
Wed Oct 19 18:09:17 EDT 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()) +
reloadFiles:
            if filename:
                if filename.endswith(".pyc"):
                    filename = filename[:-1]
                try:
                    mtime = os.stat(filename).st_mtime
                except OSError:
                    sys.exit(3) # force reload
                if filename not in mtimes:
                    mtimes[filename] = mtime
                    continue
                if mtime > mtimes[filename]:
                    sys.exit(3) # force reload
        time.sleep(1)

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
exist.




More information about the Python-list mailing list