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

Fuction zappa.async.run does not work outside lambda environment #1774

Open
erback opened this issue Feb 6, 2019 · 0 comments · May be fixed by #2129
Open

Fuction zappa.async.run does not work outside lambda environment #1774

erback opened this issue Feb 6, 2019 · 0 comments · May be fixed by #2129

Comments

@erback
Copy link

erback commented Feb 6, 2019

Context

When executing a function with zappa.async.run in a non lambda environment an error is raised. This seems to happen due to the fact that zappa tries to run the function in the lambda environment even if it's not in the lambda environment. When using the @task decorator this works as expected since there is a direct invokation of the function if AWS_LAMBDA_FUNCTION_NAME env variable is not present.

Expected Behavior

The function should be invoked directly, without errors, in a non lambda environment.

Actual Behavior

The function fails with error

Invalid type for parameter FunctionName, value: None, type: <class 'NoneType'>, valid types: <class 'str'>

Possible Fix

Change this code:

return ASYNC_CLASSES[service](lambda_function_name=lambda_function_name,

to
(copied from @task decorator)

if (service in ASYNC_CLASSES) and (lambda_function_name):
  send_result = ASYNC_CLASSES[service](lambda_function_name=lambda_function_name,
                                                     aws_region=aws_region,
                                                     capture_response=capture_response).send(task_path, args, kwargs)
   return send_result
else: #  For local exexution
  return func(*args, **kwargs)

Your Environment

  • Zappa version used: 0.47.1
  • Operating System and Python version: 3.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant