allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/2] git commit: [#5326] avoid "Broken pipe" error we were seeing, by providing ErrorMiddleware with an explicit wsgi.errors stream
Date Mon, 19 Nov 2012 19:51:42 GMT
Updated Branches:
  refs/heads/db/5326 [created] 0cdb5366c


[#5326] avoid "Broken pipe" error we were seeing, by providing ErrorMiddleware with an explicit
wsgi.errors stream


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0cdb5366
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0cdb5366
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0cdb5366

Branch: refs/heads/db/5326
Commit: 0cdb5366c1a54f81f61e6a3b3e1f6fc386931894
Parents: b932cc3
Author: Dave Brondsema <dbrondsema@geek.net>
Authored: Mon Nov 19 19:50:06 2012 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Mon Nov 19 19:51:28 2012 +0000

----------------------------------------------------------------------
 Allura/allura/command/taskd.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0cdb5366/Allura/allura/command/taskd.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/taskd.py b/Allura/allura/command/taskd.py
index 554efdb..f9bd6ef 100644
--- a/Allura/allura/command/taskd.py
+++ b/Allura/allura/command/taskd.py
@@ -59,6 +59,11 @@ class TaskdCommand(base.Command):
         if only:
             only = only.split(',')
 
+        # errors get logged via regular logging and also recorded into the mongo task record
+        # so this is generally not needed, and only present to avoid errors within
+        # weberror's ErrorMiddleware if the default error stream (stderr?) doesn't work
+        wsgi_error_log = open(pylons.config.get('taskd.wsgi_log', '/dev/null'), 'a')
+
         def start_response(status, headers, exc_info=None):
             pass
 
@@ -93,7 +98,10 @@ class TaskdCommand(base.Command):
                             only=only)
                     if self.task:
                         # Build the (fake) request
-                        r = Request.blank('/--%s--/' % self.task.task_name, dict(task=self.task))
+                        r = Request.blank('/--%s--/' % self.task.task_name,
+                                          {'task': self.task,
+                                           'wsgi.errors': wsgi_error_log,  # ErrorMiddleware
records error details here
+                                           })
                         list(wsgi_app(r.environ, start_response))
                         self.task = None
             except Exception as e:
@@ -102,6 +110,8 @@ class TaskdCommand(base.Command):
                     time.sleep(10)
                 else:
                     base.log.exception('taskd error %s' % e)
+            finally:
+                wsgi_error_log.flush()
         base.log.info('taskd pid %s stopping gracefully.' % os.getpid())
 
         if self.restart_when_done:


Mime
View raw message