Skip to content

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

@erback

Description

@erback

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions