Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
python: Fixed SCGI handler typo.
[ashd.git]
/
python
/
ashd
/
scgi.py
diff --git
a/python/ashd/scgi.py
b/python/ashd/scgi.py
index
9357e9d
..
4583fa7
100644
(file)
--- a/
python/ashd/scgi.py
+++ b/
python/ashd/scgi.py
@@
-4,6
+4,10
@@
import threading
class protoerr(Exception):
pass
class protoerr(Exception):
pass
+class closed(IOError):
+ def __init__(self):
+ super(closed, self).__init__("The client has closed the connection.")
+
def readns(sk):
hln = 0
while True:
def readns(sk):
hln = 0
while True:
@@
-74,9
+78,7
@@
def wrapwsgi(handler):
resp = []
respsent = []
resp = []
respsent = []
- def write(data):
- if not data:
- return
+ def flushreq():
if not respsent:
if not resp:
raise Exception, "Trying to write data before starting response."
if not respsent:
if not resp:
raise Exception, "Trying to write data before starting response."
@@
-86,8
+88,16
@@
def wrapwsgi(handler):
for nm, val in headers:
sk.write("%s: %s\n" % (nm, val))
sk.write("\n")
for nm, val in headers:
sk.write("%s: %s\n" % (nm, val))
sk.write("\n")
- sk.write(data)
- sk.flush()
+
+ def write(data):
+ if not data:
+ return
+ try:
+ flushreq()
+ sk.write(data)
+ sk.flush()
+ except IOError:
+ raise closed()
def startreq(status, headers, exc_info = None):
if resp:
def startreq(status, headers, exc_info = None):
if resp:
@@
-106,7
+116,8
@@
def wrapwsgi(handler):
try:
for data in respiter:
write(data)
try:
for data in respiter:
write(data)
- write("")
+ if resp:
+ flushreq()
finally:
if hasattr(respiter, "close"):
respiter.close()
finally:
if hasattr(respiter, "close"):
respiter.close()