You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2012/11/19 21:29:32 UTC
[2/2] git commit: [#5326] avoid "Broken pipe" error we were seeing,
by providing ErrorMiddleware with an explicit wsgi.errors stream
[#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/7eb79560
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7eb79560
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7eb79560
Branch: refs/heads/master
Commit: 7eb795608877f0b358aa5234b08dcaccabdee0f8
Parents: de961e2
Author: Dave Brondsema <db...@geek.net>
Authored: Mon Nov 19 19:50:06 2012 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Mon Nov 19 20:28:59 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/7eb79560/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: