From: Ben Darnell Date: Thu, 25 Feb 2010 23:49:08 +0000 (-0800) Subject: Work around an odd error I occasionally see in autoreload (which causes X-Git-Tag: v1.0.0~76^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5627d2f1613f6bf60c826bfbb84eae08f1c98e6;p=thirdparty%2Ftornado.git Work around an odd error I occasionally see in autoreload (which causes autoreload to loop endlessly without restarting the process) --- diff --git a/tornado/autoreload.py b/tornado/autoreload.py index 4b3ab364c..8fd5f88d4 100644 --- a/tornado/autoreload.py +++ b/tornado/autoreload.py @@ -27,6 +27,7 @@ import logging import os import os.path import sys +import types def start(io_loop=None, check_time=500): @@ -50,6 +51,11 @@ def _reload_on_update(io_loop, modify_times): # We already tried to reload and it didn't work, so don't try again. return for module in sys.modules.values(): + # Some modules play games with sys.modules (e.g. email/__init__.py + # in the standard library), and occasionally this can cause strange + # failures in getattr. Just ignore anything that's not an ordinary + # module. + if not isinstance(module, types.ModuleType): continue path = getattr(module, "__file__", None) if not path: continue if path.endswith(".pyc") or path.endswith(".pyo"):