X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=python%2Fashd%2Fscgi.py;h=a4342d02892016271a0157e7da40acd0cbf4053c;hb=4d2dc22a9a68395a5788ae66c84ae0ced2d0e733;hp=9357e9d1b317e829bacc7d77f12884b5a0e18e50;hpb=c06db49a3a4bfbf14b1661b667e1ed1cbab2bcd0;p=ashd.git diff --git a/python/ashd/scgi.py b/python/ashd/scgi.py index 9357e9d..a4342d0 100644 --- a/python/ashd/scgi.py +++ b/python/ashd/scgi.py @@ -74,9 +74,7 @@ def wrapwsgi(handler): 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." @@ -86,6 +84,11 @@ def wrapwsgi(handler): for nm, val in headers: sk.write("%s: %s\n" % (nm, val)) sk.write("\n") + + def write(data): + if not data: + return + flushreq() sk.write(data) sk.flush() @@ -106,7 +109,8 @@ def wrapwsgi(handler): try: for data in respiter: write(data) - write("") + if resp: + flushresp() finally: if hasattr(respiter, "close"): respiter.close()