Merge lp:~sidnei/txstatsd/catch-mod_wsgi-ioerror into lp:txstatsd

Proposed by Sidnei da Silva on 2013-01-08
Status: Merged
Approved by: Sidnei da Silva on 2013-01-09
Approved revision: 102
Merged at revision: 104
Proposed branch: lp:~sidnei/txstatsd/catch-mod_wsgi-ioerror
Merge into: lp:txstatsd
Diff against target: 28 lines (+11/-4)
1 file modified
txstatsd/client.py (+11/-4)
To merge this branch: bzr merge lp:~sidnei/txstatsd/catch-mod_wsgi-ioerror
Reviewer Review Type Date Requested Status
Anthony Lenton (community) Approve on 2013-01-09
Michael Nelson (community) 2013-01-08 Approve on 2013-01-08
Review via email: mp+142329@code.launchpad.net

Commit message

Catch IOError that can be raised by mod_wsgi when importing twisted.python.log

Description of the change

Catch IOError that can be raised by mod_wsgi when importing twisted.python.log

To post a comment you must log in.
Michael Nelson (michael.nelson) wrote :

Thanks Sidnei - I'm not sure I can vote officially, but +1 :D.

review: Approve
Anthony Lenton (elachuni) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txstatsd/client.py'
2--- txstatsd/client.py 2012-07-27 12:05:50 +0000
3+++ txstatsd/client.py 2013-01-08 14:56:25 +0000
4@@ -23,14 +23,21 @@
5
6 try:
7 import twisted
8-except ImportError:
9- # If twisted is missing, still provide the non-twisted client
10- pass
11-else:
12 from txstatsd.protocol import (
13 StatsDClientProtocol,
14 TwistedStatsDClient,
15 )
16+except (ImportError, IOError):
17+ # If twisted is missing, still provide the non-twisted client.
18+ #
19+ # The IOError happens when running code from mod_wsgi, manifested as:
20+ #
21+ # IOError: ' sys.stdout access restricted by mod_wsgi'
22+ #
23+ # ... which can happen on certain versions of twisted, because they check
24+ # for sys.stdout.encoding at the module-level of twisted.python.log. See:
25+ # http://twistedmatrix.com/trac/ticket/6244 for more details.
26+ pass
27
28 from txstatsd.hashing import ConsistentHashRing
29

Subscribers

People subscribed via source and target branches