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

Causes app to fail startup on AWS Lambda #384

Open
deceze opened this issue Sep 27, 2019 · 3 comments
Open

Causes app to fail startup on AWS Lambda #384

deceze opened this issue Sep 27, 2019 · 3 comments

Comments

@deceze
Copy link

deceze commented Sep 27, 2019

I'm trying to use django-q to enqueue tasks to AWS SQS from an AWS Lambda function. Versions involved:

  • Python 3.7
  • Django 2.2.5
  • django-q 1.0.2
  • zappa 0.48.2

This works fine in a local development environment, but putting it on Lambda using Zappa, the app fails with a somewhat cryptic log:

    raise RuntimeError("populate() isn't reentrant") in populatelicationi
[1569572571263] Instancing..
    unlink_now)ng/lib/python3.7/multiprocessing/synchronize.py", line 59, in __init___

(Yes, it's somewhat cut off somewhere.)

So, populate() isn't reentrant is some generic unhelpful error triggered by Django in case some component fails to initialise, and the following cut-off line points somewhere to the multiprocessing module. When removing django_q from the list of installed apps, the error goes away.

It would seem that django-q is trying to import something from multiprocessing that doesn't work on AWS Lambda, which causes the entire thing to fail.

I don't know whether multiprocessing is strictly required for django-q to send tasks to SQS. If possible this should be decoupled somehow. django-q would be ideal for my use case, as it allows the simple use of async_task in code to enqueue tasks, which can be configured to use orm locally during development and SQS in production. FYI, when using SQS the qcluster functionality wouldn't be used, and the SQS queue would be an event source for Lambda workers.

@lordkev
Copy link

lordkev commented Jan 21, 2020

Just hit this same issue. Were you able to figure out a resolution @deceze?

It seems that Lambda doesn't have /dev/shm and therefore doesn't support multiprocessing.Queue or multiprocessing.Pool.

https://aws.amazon.com/blogs/compute/parallel-processing-in-python-with-aws-lambda/

@deceze
Copy link
Author

deceze commented Jan 21, 2020

@lordkev I did not. I switched to dramatiq and dramatiq-sqs instead.

@lordkev
Copy link

lordkev commented Jan 21, 2020 via email

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

No branches or pull requests

2 participants