-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Need some help with this -- multiprocessing with gunicorn #1570
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
Comments
I took a look at the stack traces but I don't know what you're seeing or what's causing it. None of those traces look to be from gunicorn. Gunicorn does not use multiprocessing to spawn workers, it uses os.fork(). My best guess is that maybe you're using multiprocessing to start your other process, and then just invoking Gunicorn. Maybe Gunicorn and multiprocessing are both catching and handling the keyboard interrupt. If you're not already, can you try using multiprocessing to start two processes, one for your background process and one for gunicorn, and then just have the main processes join them both? |
Hi @tilgovi , Im thinking over your idea of using a separate process for gunicorn, but it may not help my process. I am not completely sure, but do you think if i do what i am doing in a separate thread, will the os.fork() copy the thread too? I need to be in gunicorns process space. |
I do not know what to advise you to do here. Is there more I can do to help? |
No, I think not. Thanks or the clarification. I could have done os.fork() myself but that would make my code not be cross platform. I guess this maybe why (one of the reasons) gunicorn doesn't run on windows. I'll try something on my end. Thanks |
It's true! If you watch #524 for updates, I expect we might move to multiprocessing in a future release in order to support Windows. Then, you might have an easier time with this. |
did you try to launch multiprocess in the |
@tilgovi there are many reason we are not using multiprocessing though. one is to have a better supervision that the one offered by this module. |
@benoitc Thank you for that suggestion. I did see it, And I did consider it at one point. But I am limited by my own constraints
I could run my code as threading.Thread threads, but that may hinder the listener process performance - I haven't checked the numbers yet. Also I'm a bit afraid about this here |
@benoitc Unless there is a way to dynamically tell what when_ready is to do |
i guess you can enrich the config directly before loading gunicorn. on the other hand i think the issue comes from having the atexit function which is apparently shared between the processes. I think gunicorn should take care of it when a worker is spawned |
Yeah, the atexit functioning is done by the multiprocessing library. I'll let you guys know how I handled it. All this happens because of the dumb copy that os.fork() does. I agree that it is on the developer to take care of the dumbness but since this os.fork() is inside gunicorn - It's something I cannot control. It might b a week before I can get anything done on this issue though. |
Uh oh!
There was an error while loading. Please reload this page.
https://stackoverflow.com/questions/45697850/error-when-closing-master-process-multiprocessing
Sorry, I didn't know how else to contact you guys @benoitc . Any help is appreciated. The error traces are from gunicorn
The text was updated successfully, but these errors were encountered: