Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c221b22
)
python: Use with statements in python3 wsgidir.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Tue, 13 Dec 2011 02:04:21 +0000
(
03:04
+0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Tue, 13 Dec 2011 02:04:21 +0000
(
03:04
+0100)
python3/ashd/wsgidir.py
patch
|
blob
|
blame
|
history
diff --git
a/python3/ashd/wsgidir.py
b/python3/ashd/wsgidir.py
index
cc17b9b
..
d4289a7
100644
(file)
--- a/
python3/ashd/wsgidir.py
+++ b/
python3/ashd/wsgidir.py
@@
-87,8
+87,7
@@
def getmod(path):
about the module. See its documentation for details.
"""
sb = os.stat(path)
about the module. See its documentation for details.
"""
sb = os.stat(path)
- cachelock.acquire()
- try:
+ with cachelock:
if path in modcache:
entry = modcache[path]
if sb.st_mtime <= entry.mtime:
if path in modcache:
entry = modcache[path]
if sb.st_mtime <= entry.mtime:
@@
-106,16
+105,13
@@
def getmod(path):
entry = cachedmod(mod, sb.st_mtime)
modcache[path] = entry
return entry
entry = cachedmod(mod, sb.st_mtime)
modcache[path] = entry
return entry
- finally:
- cachelock.release()
def chain(env, startreq):
path = env["SCRIPT_FILENAME"]
mod = getmod(path)
entry = None
if mod is not None:
def chain(env, startreq):
path = env["SCRIPT_FILENAME"]
mod = getmod(path)
entry = None
if mod is not None:
- mod.lock.acquire()
- try:
+ with mod.lock:
if hasattr(mod, "entry"):
entry = mod.entry
else:
if hasattr(mod, "entry"):
entry = mod.entry
else:
@@
-124,8
+120,6
@@
def chain(env, startreq):
elif hasattr(mod.mod, "application"):
entry = mod.mod.application
mod.entry = entry
elif hasattr(mod.mod, "application"):
entry = mod.mod.application
mod.entry = entry
- finally:
- mod.lock.release()
if entry is not None:
return entry(env, startreq)
return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "Invalid WSGI handler.")
if entry is not None:
return entry(env, startreq)
return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "Invalid WSGI handler.")