-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Gunicorn RecursionError with gevent and requests in python 3.6.2 #1559
Comments
Thank you for the report. Unfortunately, we need to see the full traceback and a minimal reproducer in order to track down the problem. |
|
Is this enough? This happens when gunicorn is running, and I use another python script to make a request to the server. My command of running gunicorn is |
That looks like gevent/gevent#941, ie, incorrect monkey-patching order. |
Is there a way to change the monkey patch order in the gunicorn setup? Right now in my code I've never type any "monkey-patch-all", I just use |
Speaking only for myself, I have found the order in which gunicorn preload and monkey-patches to be incompatible. Instead, we use a wrapper script; in principle it's something like: import gevent.monkey; gevent.monkey.patch_all()
import gunicorn
gunicorn.main() |
It seems like I develop in a very different (and probably worse) way than how you did it. In my code, my code looks like a standard flask app, and in my code there's no |
The way you develop has nothing to do with this. This is simply about deployment. I deploy with (roughly) the script I shared because |
I see, would you mind suggest me a deployment script that I can use to run my code that can fix this monkey patch order issue? Originally I thought the deployment script would be a bash script that's similar to the line I share above but it seems like you are also using python for this, then I don't know how can you feed in those parameters (or even simulate the New relic line...?). I just have a gqa.py in the gqa folder that I want to use gunicorn to run it. |
It's both trivial and depends on your app. Our app uses Pyramid, so we simply have a setuptools # Note that we must not import *anything* before the patch
from nti.monkey import patch_nti_pserve_on_import
patch_nti_pserve_on_import.patch() # gevent.monkey.patch_all()
import sys
from pkg_resources import load_entry_point, get_distribution
def main():
sys.exit(
load_entry_point('pyramid', 'console_scripts', 'pserve')()
)
if __name__ == '__main__':
sys.exit(main()) |
I should add, we absolutely depend on |
Thanks, your suggestions are extremely helpful (Although I am still not sure how to use my own deployment script as I have no experience on that). But will probably looking into |
Thanks for the details. I think this is more or less a duplicate of #1056. |
We can close this one now. |
I have a simple flask script that uses requests to make http requests to third party web service. The way I run the script in gunicorn is
gunicorn abc:APP -b 0.0.0.0:8080 -w 4 -k gevent --timeout 30 --preload
However, after I upgrade the code to python 3.6.2, I can still run the server, but whenever the webserver received a request, it shows
RecursionError: maximum recursion depth exceeded while calling a Python object
on every worker, and the server seems are still running. When I change the running command to
gunicorn abc:APP -b 0.0.0.0:8080 -w 4 --timeout 30 --preload
It all works again. So is there any issue with gunicorn's async worker and requests in python 3.6.2? Is there a way to fix this?
The text was updated successfully, but these errors were encountered: