X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=python%2Fashd%2Fwsgidir.py;h=991b9f6e08e5aceb462612398acfdd3c9183b1a6;hp=8b473f2844b1450e98f38136751673ce94972792;hb=7fe08a6fe8661e0429e2f2da599bdf84523dc5d5;hpb=58c3e8b181230a562851ca4dadaeb38ace76a08f diff --git a/python/ashd/wsgidir.py b/python/ashd/wsgidir.py index 8b473f2..991b9f6 100644 --- a/python/ashd/wsgidir.py +++ b/python/ashd/wsgidir.py @@ -55,7 +55,7 @@ class cachedmod(object): Additional data attributes can be arbitrarily added for recording any meta-data about the module. """ - def __init__(self, mod, mtime): + def __init__(self, mod = None, mtime = -1): self.lock = threading.Lock() self.mod = mod self.mtime = mtime @@ -91,23 +91,28 @@ def getmod(path): try: if path in modcache: entry = modcache[path] - if sb.st_mtime <= entry.mtime: - return entry - - f = open(path) - try: - text = f.read() - finally: - f.close() - code = compile(text, path, "exec") - mod = types.ModuleType(mangle(path)) - mod.__file__ = path - exec code in mod.__dict__ - entry = cachedmod(mod, sb.st_mtime) - modcache[path] = entry - return entry + else: + entry = cachedmod() + modcache[path] = entry finally: cachelock.release() + entry.lock.acquire() + try: + if entry.mod is None or sb.st_mtime > entry.mtime: + f = open(path, "r") + try: + text = f.read() + finally: + f.close() + code = compile(text, path, "exec") + mod = types.ModuleType(mangle(path)) + mod.__file__ = path + exec code in mod.__dict__ + entry.mod = mod + entry.mtime = sb.st_mtime + return entry + finally: + entry.lock.release() def chain(env, startreq): path = env["SCRIPT_FILENAME"]