~ori-livneh/txstatsd/wikimedia

« back to all changes in this revision

Viewing changes to txstatsd/client.py

  • Committer: Tarmac
  • Author(s): Sidnei da Silva
  • Date: 2013-01-09 12:52:44 UTC
  • mfrom: (101.2.1 catch-mod_wsgi-ioerror)
  • Revision ID: tarmac@u1-server-deps-tarmac-lucid-20130109125244-9v3qmhu68odkxo5j
[r=elachuni,michael.nelson] Catch IOError that can be raised by mod_wsgi when importing twisted.python.log

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
try:
25
25
    import twisted
26
 
except ImportError:
27
 
    # If twisted is missing, still provide the non-twisted client
28
 
    pass
29
 
else:
30
26
    from txstatsd.protocol import (
31
27
        StatsDClientProtocol,
32
28
        TwistedStatsDClient,
33
29
    )
 
30
except (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
        
35
42
from txstatsd.hashing import ConsistentHashRing
36
43