3

I am beginner of django and zappa. And I am trying to deploy django application using zappa on AWS lambda. Also, I'd like to connect RDS database (postgres).

To create database, I entered "zappa manage dev create_db" Then, error message occurred as below. And I don't know how to solve this. Other solutions on the Internet didn't work for me.

populate() isn't reentrant: RuntimeError
Traceback (most recent call last):
  File "/var/task/handler.py", line 509, in lambda_handler
    return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 240, in lambda_handler
    return handler.handler(event, context)
  File "/var/task/handler.py", line 372, in handler
    app_function = get_django_wsgi(self.settings.DJANGO_SETTINGS)
  File "/var/task/zappa/ext/django_zappa.py", line 20, in get_django_wsgi
    return get_wsgi_application()
  File "/var/task/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/var/task/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/var/task/django/apps/registry.py", line 81, in populate
    raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant

zappa_settings.json is

{
    "dev": {
        "django_settings": "test_zappa_13.settings",
        "aws_region": "ap-northeast-2",
        "profile_name": "default",
        "project_name": "test-zappa-13",
        "runtime": "python3.6",
        "s3_bucket": "zappa-rw2difr3r"
    }
}

django settings.py is

INSTALLED_APPS = [ 'zappa_django_utils', ... ]

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'blah', 'USER': 'blahblah', 'PASSWORD': 'blahblah', 'HOST': 'postgres-instance-1.test1234.ap-northeast-2.rds.amazonaws.com', 'PORT': 5432, } } ...

And, Django version == 2.2, Python version == 3.6, Zappa version == 0.45.1

Please help me to solve this problem.

References

  1. https://www.codingforentrepreneurs.com/blog/rds-database-serverless-django-zappa-aws-lambda
  2. https://www.agiliq.com/blog/2019/01/complete-serverless-django/
Seung-hee Han
  • 75
  • 1
  • 9

1 Answers1

0

I had the exactly same error as you. In my case, the problem was that I simply forgot to update the deployment by running 'zappa update dev' again after I updated the settings.

jeongin
  • 23
  • 4