From b9c4e937731ca1d4186a00abf0d0a069368cf1e0 Mon Sep 17 00:00:00 2001 From: SteveParadox <39016370+SteveParadox@users.noreply.github.com> Date: Fri, 17 Jul 2020 05:09:46 +0100 Subject: [PATCH] Update asynchronous.py --- zappa/asynchronous.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/zappa/asynchronous.py b/zappa/asynchronous.py index ab3296d5b..dbf5838f4 100644 --- a/zappa/asynchronous.py +++ b/zappa/asynchronous.py @@ -179,8 +179,11 @@ def _send(self, message): """ message['command'] = 'zappa.asynchronous.route_lambda_task' payload = json.dumps(message).encode('utf-8') - if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover - raise AsyncException("Payload too large for async Lambda call") + try: + if len(payload) >= LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover + raise AsyncException("Payload too large for async Lambda call") + except Exception as e: + return None self.response = self.client.invoke( FunctionName=self.lambda_function_name, InvocationType='Event', #makes the call async @@ -245,8 +248,11 @@ def _send(self, message): """ message['command'] = 'zappa.asynchronous.route_sns_task' payload = json.dumps(message).encode('utf-8') - if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover - raise AsyncException("Payload too large for SNS") + try: + if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover + raise AsyncException("Payload too large for SNS") + except Exception as e: + return None self.response = self.client.publish( TargetArn=self.arn, Message=payload @@ -457,10 +463,14 @@ def import_and_get_task(task_path): """ module, function = task_path.rsplit('.', 1) app_module = importlib.import_module(module) - app_function = getattr(app_module, function) + app_function = getattr(*arg, **kwarg) + if hasattr(app_module, function): + app_function = getattr(app_module, function) return app_function + + def get_func_task_path(func): """ Format the modular task path for a function via inspection.