X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=python%2Fashd%2Fscgi.py;h=4583fa73769e0ec6f94f5f71bf511e878d9d32d8;hb=1b16086880096c31abd31fa2dae40e5b36789162;hp=a4342d02892016271a0157e7da40acd0cbf4053c;hpb=699754de7dc11275d9d94eb521111609a6d73ed7;p=ashd.git diff --git a/python/ashd/scgi.py b/python/ashd/scgi.py index a4342d0..4583fa7 100644 --- a/python/ashd/scgi.py +++ b/python/ashd/scgi.py @@ -4,6 +4,10 @@ import threading 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: @@ -88,9 +92,12 @@ def wrapwsgi(handler): def write(data): if not data: return - flushreq() - sk.write(data) - sk.flush() + try: + flushreq() + sk.write(data) + sk.flush() + except IOError: + raise closed() def startreq(status, headers, exc_info = None): if resp: @@ -110,7 +117,7 @@ def wrapwsgi(handler): for data in respiter: write(data) if resp: - flushresp() + flushreq() finally: if hasattr(respiter, "close"): respiter.close()