python: Catch some previously uncaught errors in rplex handler.
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 5 Jan 2014 22:42:39 +0000 (23:42 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 5 Jan 2014 22:42:39 +0000 (23:42 +0100)
python3/ashd/serve.py

index 9aae12c..f116518 100644 (file)
@@ -272,15 +272,22 @@ class resplex(handler):
                         data = next(respiter)
                     except StopIteration:
                         rem = True
-                        req.flushreq()
+                        try:
+                            req.flushreq()
+                        except:
+                            log.error("exception occurred when handling response data", exc_info=True)
                     except:
                         rem = True
                         log.error("exception occurred when iterating response", exc_info=True)
                     if not rem:
                         if data:
-                            req.flushreq()
-                            req.writedata(data)
-                    else:
+                            try:
+                                req.flushreq()
+                                req.writedata(data)
+                            except:
+                                log.error("exception occurred when handling response data", exc_info=True)
+                                rem = True
+                    if rem:
                         current[req] = None
                         try:
                             if hasattr(respiter, "close"):