From 7aefe4e52008d8b36db5ebc60e88a7f89c57ef60 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 7 Jan 2019 00:07:45 +0100 Subject: [PATCH] More resilient logic in case actions in a procedure return null responses --- platypush/message/request/__init__.py | 3 ++- platypush/procedure/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/platypush/message/request/__init__.py b/platypush/message/request/__init__.py index 1f21d422e..9bf1c008a 100644 --- a/platypush/message/request/__init__.py +++ b/platypush/message/request/__init__.py @@ -194,7 +194,8 @@ class Request(Message): if self.action.startswith('procedure.'): context['n_tries'] = n_tries response = self._execute_procedure(**context) - self._send_response(response) + if response is not None: + self._send_response(response) return response else: (module_name, method_name) = get_module_and_method_from_action(self.action) diff --git a/platypush/procedure/__init__.py b/platypush/procedure/__init__.py index 9d4a79f2c..1957f2335 100644 --- a/platypush/procedure/__init__.py +++ b/platypush/procedure/__init__.py @@ -139,7 +139,7 @@ class Procedure(object): context['_async'] = self._async; context['n_tries'] = n_tries response = request.execute(**context) - if not self._async: + if not self._async and response: if isinstance(response.output, dict): for (k,v) in response.output.items(): context[k] = v @@ -147,7 +147,7 @@ class Procedure(object): context['output'] = response.output context['errors'] = response.errors - return response + return response or Response() class LoopProcedure(Procedure):