Skip to content

Commit

Permalink
Keep context for logging intact in greenthreads
Browse files Browse the repository at this point in the history
 * fixes bug 942918

Change-Id: Ia0fcf459c53b95a8675472adcfbba08014e34e5b
  • Loading branch information
vishvananda committed Mar 15, 2012
1 parent 97eb928 commit 4012a3f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion nova/context.py
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions nova/image/s3.py
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion nova/rpc/amqp.py
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion nova/rpc/impl_carrot.py
Expand Up @@ -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!
Expand Down

0 comments on commit 4012a3f

Please sign in to comment.