summaryrefslogtreecommitdiffstats
path: root/nova/common
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes.erdfelt@rackspace.com>2012-06-07 22:59:41 +0000
committerJohannes Erdfelt <johannes.erdfelt@rackspace.com>2012-06-07 23:11:39 +0000
commitdfa9e5210cc3569dc2d5d8fc3ea45e610c766ffc (patch)
tree54e9ae5baffaae8572427838034e89422b40b42a /nova/common
parent089300fd4bcecaacd2ea3fa345a1b6b2c5b2ab61 (diff)
downloadnova-dfa9e5210cc3569dc2d5d8fc3ea45e610c766ffc.tar.gz
nova-dfa9e5210cc3569dc2d5d8fc3ea45e610c766ffc.tar.xz
nova-dfa9e5210cc3569dc2d5d8fc3ea45e610c766ffc.zip
Make eventlet backdoor play nicer with gettext
Fixes bug 1010236 Implement a new sys.displayhook that doesn't overwrite __builtin__._ that was set by gettext Change-Id: Id3c0a331eb6f98240fe1e4d0b083c72e28f99c53
Diffstat (limited to 'nova/common')
-rw-r--r--nova/common/eventlet_backdoor.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/nova/common/eventlet_backdoor.py b/nova/common/eventlet_backdoor.py
index c2d4b74bf..b67608691 100644
--- a/nova/common/eventlet_backdoor.py
+++ b/nova/common/eventlet_backdoor.py
@@ -17,6 +17,8 @@
# under the License.
import gc
+import pprint
+import sys
import traceback
import eventlet
@@ -52,7 +54,6 @@ def print_greenthreads():
backdoor_locals = {
- '_': None, # So it doesn't interfere with the global
'exit': dont_use_this, # So we don't exit the entire process
'quit': dont_use_this, # So we don't exit the entire process
'fo': find_objects,
@@ -64,6 +65,16 @@ def initialize_if_enabled():
if FLAGS.backdoor_port is None:
return
+ # NOTE(johannes): The standard sys.displayhook will print the value of
+ # the last expression and set it to __builtin__._, which overwrites
+ # the __builtin__._ that gettext sets. Let's switch to using pprint
+ # since it won't interact poorly with gettext, and it's easier to
+ # read the output too.
+ def displayhook(val):
+ if val is not None:
+ pprint.pprint(val)
+ sys.displayhook = displayhook
+
eventlet.spawn(eventlet.backdoor.backdoor_server,
eventlet.listen(('localhost', FLAGS.backdoor_port)),
locals=backdoor_locals)