Finding absolute path of imported module?

Roy Smith roy at panix.com
Tue Jun 19 13:55:49 EDT 2012


We're trying to debug a weird (and, of course, intermittent) problem a
gunicorn-based web application.  Our production directory structure
looks like:

deploy/
  rel-2012-06-14/
  rel-2012-06-12/
  rel-2012-06-11/
  current -> rel-2012006-14

Each time we deploy a new version, we create a new release directory,
move the "current" symlink, and restart gunicorn.  We've seen
instances where some of the workers end up importing some modules from
one directory and some from another (i.e. the old and new targets of
current).

So, the question is, is there any way to dump all the *absolute*
pathnames of all the imported modules?  I can iterate over
sys.modules.values(), but that doesn't give me absolute pathnames, so
I can't tell which version of the symlink existed when the module was
imported.



More information about the Python-list mailing list