How to prevent monkey patch when gunicorn is loaded?

Viewed 239

I am using gunicorn with two gevent workers for deploying a flask application. So, i manually monkey patch before the gunicorn loaded like this.

from gevent import monkey
monkey.patch_all(subprocess=False)

import os
import logging
import requests
...

but, when i start the gunicorn server, these warning is issued from the gunicorn.

../lib/python3.9/site-packages/gunicorn/workers/ggevent.py:38: 
MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched monkey.patch_all()

I think the reason why these warning occur is because the gunicorn automatically execute monkey patching. So I comment out the code for monkey patching and restart the gunicorn server, another warning occurs.

../lib/python3.9/site-packages/gunicorn/workers/ggevent.py:38: 
MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier.

how to fix these warnings? or Can I ignore these warnings?

0 Answers
Related