By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,767 Members | 2,114 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,767 IT Pros & Developers. It's quick & easy.

possible bug in cherrypy.lib.autoreloader

P: n/a
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)

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 '' which does not

Oct 19 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Ok, so it turns out that the problem the cherrypy.lib.autoreload module
is having, is that kid imports elementtree and on my machine the
elementtree modules are inside a zip file (.egg). So the "path" to the
elementtree file is not a valid OS path because everything
after the .egg file is inside the file.

Is there a quick way of determining that a module was imported from a
zip file, or that a module's __file__ attribute is a valid path as far
as Python is concerned, even though it doesn't exist to the OS?

Oct 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.