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

Proposed by Sidnei da Silva
Status: Merged
Approved by: Sidnei da Silva
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
Michael Nelson (community) Approve
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.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

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

review: Approve
Revision history for this message
Anthony Lenton (elachuni) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'txstatsd/client.py'
--- txstatsd/client.py 2012-07-27 12:05:50 +0000
+++ txstatsd/client.py 2013-01-08 14:56:25 +0000
@@ -23,14 +23,21 @@
2323
24try:24try:
25 import twisted25 import twisted
26except ImportError:
27 # If twisted is missing, still provide the non-twisted client
28 pass
29else:
30 from txstatsd.protocol import (26 from txstatsd.protocol import (
31 StatsDClientProtocol,27 StatsDClientProtocol,
32 TwistedStatsDClient,28 TwistedStatsDClient,
33 )29 )
30except (ImportError, IOError):
31 # If twisted is missing, still provide the non-twisted client.
32 #
33 # The IOError happens when running code from mod_wsgi, manifested as:
34 #
35 # IOError: ' sys.stdout access restricted by mod_wsgi'
36 #
37 # ... which can happen on certain versions of twisted, because they check
38 # for sys.stdout.encoding at the module-level of twisted.python.log. See:
39 # http://twistedmatrix.com/trac/ticket/6244 for more details.
40 pass
34 41
35from txstatsd.hashing import ConsistentHashRing42from txstatsd.hashing import ConsistentHashRing
3643

Subscribers

People subscribed via source and target branches