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

Unable to launch gunicorn + gevent: OSError: [Errno 92] Protocol not available #3149

Open
xingdongzhe opened this issue Feb 3, 2024 · 0 comments
Assignees

Comments

@xingdongzhe
Copy link

xingdongzhe commented Feb 3, 2024

@benoitc I found that gunicorn launch fail with gevent

  • It only launch fail when Python version >= 3.7, this is because of gevent support for Python3.7
  • here code to repduce: gunicorn -c gunicorn_config.py main:app
  • Python==3.8.15
  • gunicorn ==21.2.0
  • gevent==23.9.1
# gunicorn_config.py

# import gevent.monkey

# gevent.monkey.patch_all()
import logging

bind = "127.0.0.1:8888"
workers = 1

backlog = 2048
worker_class = "gevent"
# worker_class = "tornado"
# worker_class = "uvicorn.workers.UvicornWorker"
debug = True
worker_connections = 3

chdir = "."
daemon = False
accesslog = "./access.log"
errorlog = "./error.log"
loglevel = "debug"

# main.py
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"
  • errlog.log output
[2024-02-03 17:02:36 +0800] ERROR /home/linsg/work/tornado_demo/venv/lib/python3.8/site-packages/gunicorn/glogging.py 284 15652 139651797619584 Exception in worker process
Traceback (most recent call last):
  File "/home/linsg/work/tornado_demo/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/home/linsg/work/tornado_demo/venv/lib/python3.8/site-packages/gunicorn/workers/ggevent.py", line 145, in init_process
    self.patch()
  File "/home/linsg/work/tornado_demo/venv/lib/python3.8/site-packages/gunicorn/workers/ggevent.py", line 44, in patch
    sockets.append(socket.socket(s.FAMILY, socket.SOCK_STREAM,
  File "/home/linsg/work/tornado_demo/venv/lib/python3.8/site-packages/gevent/_socket3.py", line 125, in __init__
    self._sock = self._gevent_sock_class(family, type, proto, fileno)
OSError: [Errno 92] Protocol not available
  • gevent suport for Python3.7
  • proto paramater change default value to -1 when fileno is not None. When proto=-1 will get overview output
  • And gunicorn code of socket's configuration will use the default value that is -1 for proto
sockets.append(socket.socket(s.FAMILY, socket.SOCK_STREAM, fileno=s.sock.fileno()))
@benoitc benoitc self-assigned this Feb 4, 2024
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