From 4012a3f792ca5958616b31f7594f200d18665d71 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 15 Mar 2012 13:02:07 -0700 Subject: [PATCH] Keep context for logging intact in greenthreads * fixes bug 942918 Change-Id: Ia0fcf459c53b95a8675472adcfbba08014e34e5b --- nova/context.py | 5 ++++- nova/image/s3.py | 1 + nova/rpc/amqp.py | 2 +- nova/rpc/impl_carrot.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nova/context.py b/nova/context.py index c5c3162fb40..cab8b2d4b21 100644 --- a/nova/context.py +++ b/nova/context.py @@ -81,7 +81,10 @@ def __init__(self, user_id, project_id, is_admin=None, read_deleted="no", self.request_id = request_id self.auth_token = auth_token if overwrite or not hasattr(local.store, 'context'): - local.store.context = self + self.update_store() + + def update_store(self): + local.store.context = self def to_dict(self): return {'user_id': self.user_id, diff --git a/nova/image/s3.py b/nova/image/s3.py index 570dfea19cd..fdf95551552 100644 --- a/nova/image/s3.py +++ b/nova/image/s3.py @@ -283,6 +283,7 @@ def _s3_create(self, context, metadata): def delayed_create(): """This handles the fetching and decrypting of the part files.""" + context.update_store() log_vars = {'image_location': image_location, 'image_path': image_path} metadata['properties']['image_state'] = 'downloading' diff --git a/nova/rpc/amqp.py b/nova/rpc/amqp.py index 367eaf1e884..e620ea36c64 100644 --- a/nova/rpc/amqp.py +++ b/nova/rpc/amqp.py @@ -244,7 +244,7 @@ def _process_data(self, ctxt, method, args): """Thread that magically looks for a method on the proxy object and calls it. """ - + ctxt.update_store() try: node_func = getattr(self.proxy, str(method)) node_args = dict((str(k), v) for k, v in args.iteritems()) diff --git a/nova/rpc/impl_carrot.py b/nova/rpc/impl_carrot.py index cc124c25d14..22586b1a9a2 100644 --- a/nova/rpc/impl_carrot.py +++ b/nova/rpc/impl_carrot.py @@ -283,7 +283,7 @@ def _process_data(self, ctxt, method, args): """Thread that magically looks for a method on the proxy object and calls it. """ - + ctxt.update_store() node_func = getattr(self.proxy, str(method)) node_args = dict((str(k), v) for k, v in args.iteritems()) # NOTE(vish): magic is fun!