From dfa9e5210cc3569dc2d5d8fc3ea45e610c766ffc Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Thu, 7 Jun 2012 22:59:41 +0000 Subject: 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 --- nova/common/eventlet_backdoor.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) -- cgit