X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=python%2Fashd%2Fscgi.py;h=a4342d02892016271a0157e7da40acd0cbf4053c;hb=699754de7dc11275d9d94eb521111609a6d73ed7;hp=9357e9d1b317e829bacc7d77f12884b5a0e18e50;hpb=4d7cf6cba43bf1dc072b571d1b62cf214d9a7a10;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()