-
-
Notifications
You must be signed in to change notification settings - Fork 294
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
foo.bar.tasks.my_task fails with "No module named bar.tasks" when running in AWS / Elastic Beanstalk #105
Comments
Did another test: I tried moving the tasks.py up to the app root so the call is now: async('myapp.tasks.test_task', request.user) And the error message:
Also tried moving the task function into views.py: async('myapp.views.test_task', request.user) Same problem:
I'm stumped. |
You will need the exact same environment variables as you have on your webserver. Most importantly the You could try running |
Explicitly copies the environment from the Cluster into the Sentinel and all worker processes. Fixes Koed00#105
I'm not convinced yet about this pull request. I feel it is quite a big change for something that might not even be a real issue. I have several Heroku deployments, Digital Ocean, Docker, Docker-Compose and Amazone ECS setups I administer with multiple web instances and redundant worker clusters and I've never seen this import problem before. I feel if we spend a little time with it we could probably fix your problem without a pull request. The reasoning behind it is that the environment does not need to be copied to the individual worker processes. Each is a complete fork of the spawning process and even uses the same memory space, so they run in the exact same environment. |
Yes, you were right. My fix was not actually the solution and the pull request should be deleted. But the good news is that I now have a workaround! Here's a better understanding of what seems to be happening:
So, weird as it sounds, when the original environment is destroyed, qcluster acts as if it can no longer find my app, even though the new app is now serving exactly where the old one used to be! Perhaps it's some internal EB symlinking that's leaving the qcluster pointing to the old code that has since been deleted. I've confirmed that if I manually kill the qcluster after the new code is deployed, when it respawns everything will work as expected. This is how I inadvertently tricked myself into thinking that my My workaround:
|
I've been reading up on supervisor, cause I've mostly been using Mozzilla's circus. I think your thoughts on the situation are correct. According to supervisors docs, it doesn't like daemonizing or forking processes. It actually modifies the environment with some of it own settings and I'm hypothesizing this might be happening in a way that leads to the problems you're seeing. Btw. You always need to restart the clusters after deploying new code, cause you might be trying to queue tasks that just don't exist yet in the cluster copy of your Django project. I've just never seen that the environment completely disappears. Good stuff to learn about though. |
So now I've got qcluster happily running under supervisord both in local dev and on Elastic Beanstalk (EB). Local testing works great.
I have a simple test task:
And I can make an
async
call on it in local dev:And it runs fine:
But up on Elastic Beanstalk something strange is going on with traversing the app structure:
I also tried passing the function directly:
But end up with a similar error:
Same problem if I do a relative import:
The EB supervisord.conf is straightforward:
(
$djangoenv
is injecting the environment variables elsewhere in the deploy script, but didn't make a difference with or without them):I also tried SSHing into EB and doing a manual
async
call through themanage.py shell
but saw the same errors in the qcluster logs.Nothing crazy about the project structure:
Running on Python 2.7.9.
This seems most likely to be something with the EB environment, but let me know if you have any ideas. I'm all out at this point!
The text was updated successfully, but these errors were encountered: