forked from platypush/platypush
Errors should be caught also before a request action is executed (prevents HTTP timeouts when the error is on e.g. get_plugin() level)
This commit is contained in:
parent
fa17011b24
commit
e3f0219554
1 changed files with 20 additions and 12 deletions
|
@ -207,21 +207,29 @@ class Request(Message):
|
||||||
def _thread_func(_n_tries, errors=None):
|
def _thread_func(_n_tries, errors=None):
|
||||||
response = None
|
response = None
|
||||||
|
|
||||||
if self.action.startswith('procedure.'):
|
try:
|
||||||
context['n_tries'] = _n_tries
|
if self.action.startswith('procedure.'):
|
||||||
response = self._execute_procedure(**context)
|
context['n_tries'] = _n_tries
|
||||||
if response is not None:
|
response = self._execute_procedure(**context)
|
||||||
|
if response is not None:
|
||||||
|
self._send_response(response)
|
||||||
|
return response
|
||||||
|
# utils.get_context is a special action that simply returns the current context
|
||||||
|
elif self.action == 'utils.get_context':
|
||||||
|
response = Response(output=context)
|
||||||
self._send_response(response)
|
self._send_response(response)
|
||||||
return response
|
return response
|
||||||
# utils.get_context is a special action that simply returns the current context
|
else:
|
||||||
elif self.action == 'utils.get_context':
|
action = self.expand_value_from_context(self.action, **context)
|
||||||
response = Response(output=context)
|
(module_name, method_name) = get_module_and_method_from_action(action)
|
||||||
|
plugin = get_plugin(module_name)
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(e)
|
||||||
|
msg = 'Uncaught pre-processing exception from action [{}]: {}'.format(self.action, str(e))
|
||||||
|
logger.warning(msg)
|
||||||
|
response = Response(output=None, errors=[msg])
|
||||||
self._send_response(response)
|
self._send_response(response)
|
||||||
return response
|
return response
|
||||||
else:
|
|
||||||
action = self.expand_value_from_context(self.action, **context)
|
|
||||||
(module_name, method_name) = get_module_and_method_from_action(action)
|
|
||||||
plugin = get_plugin(module_name)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Run the action
|
# Run the action
|
||||||
|
|
Loading…
Reference in a new issue