Skip to content

Commit

Permalink
[r=elachuni,michael.nelson] Catch IOError that can be raised by mod_w…
Browse files Browse the repository at this point in the history
…sgi when importing twisted.python.log
  • Loading branch information
Sidnei da Silva authored and Tarmac committed Jan 9, 2013
2 parents ef0c305 + 4687297 commit d8c3c93
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions txstatsd/client.py
Expand Up @@ -23,14 +23,21 @@

try:
import twisted
except ImportError:
# If twisted is missing, still provide the non-twisted client
pass
else:
from txstatsd.protocol import (
StatsDClientProtocol,
TwistedStatsDClient,
)
except (ImportError, IOError):
# If twisted is missing, still provide the non-twisted client.
#
# The IOError happens when running code from mod_wsgi, manifested as:
#
# IOError: ' sys.stdout access restricted by mod_wsgi'
#
# ... which can happen on certain versions of twisted, because they check
# for sys.stdout.encoding at the module-level of twisted.python.log. See:
# http://twistedmatrix.com/trac/ticket/6244 for more details.
pass

from txstatsd.hashing import ConsistentHashRing

Expand Down

0 comments on commit d8c3c93

Please sign in to comment.