Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestContext #27843

Merged
merged 11 commits into from
Oct 26, 2015
4 changes: 2 additions & 2 deletions salt/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def run(self):
pr = activate_profile(profiling_enabled)
try:
ret = runner.run()
if isinstance(ret, dict) and 'retcode' in ret:
self.exit(ret['retcode'])
finally:
output_profile(
pr,
stats_path=self.options.profiling_path,
stop=True)
if isinstance(ret, dict) and 'retcode' in ret:
self.exit(ret['retcode'])

except SaltClientError as exc:
raise SystemExit(str(exc))
21 changes: 12 additions & 9 deletions salt/client/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import traceback
import collections
import multiprocessing
import tornado.stack_context

# Import Salt libs
import salt.exceptions
Expand Down Expand Up @@ -84,13 +85,13 @@ def wrapper(*args, **kwargs):

user = salt.utils.get_specific_user()
return self.client._proc_function(
key,
low,
user,
async_pub['tag'], # TODO: fix
async_pub['jid'], # TODO: fix
False, # Don't daemonize
)
key,
low,
user,
async_pub['tag'], # TODO: fix
async_pub['jid'], # TODO: fix
False, # Don't daemonize
)
return wrapper

def __len__(self):
Expand Down Expand Up @@ -333,8 +334,10 @@ def low(self, fun, low):
else:
kwargs = low['kwargs']

data['return'] = self.functions[fun](*args, **kwargs)
data['success'] = True
# Initialize a context for executing the method.
with tornado.stack_context.StackContext(self.functions.context_dict.clone):
data['return'] = self.functions[fun](*args, **kwargs)
data['success'] = True
except (Exception, SystemExit) as ex:
if isinstance(ex, salt.exceptions.NotImplemented):
data['return'] = str(ex)
Expand Down
Loading