-
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
OSError: [Errno 9] Bad file descriptor #1877
Comments
@leond08 Thanks for the ticket! In order to understand how it is happening can you provide a little more info?
|
I'm using gunicorn3 latest version I start my background task after a user clicked the button |
Had the same issue with aiohttp + gunicorn, observe the same message each time when ctrl + c. [INFO] Error while closing socket [Errno 9] Bad file descriptor |
I don't reproduce it. I suspect your application is closing some fds which create the issue above. |
We are experiencing the same issue, only thing is it's only happening on 1 out of 8 containers running in docker swarm. |
We have experienced the same issue with 1 out of 9 containers, it looks like related to docker and python3 and gevent. |
gunicorn 20.0.4 + aiohttp 3.6.2 Gunicorn is running as dev server:
Almost every Ctrl+C ends with
It does not matter if application handled any request or not. |
With Sanic 20.3.0:
|
Same here with Gunicorn 20.0.4 + Uvicorn 0.11.5 worker class on every Ctrl+C
|
any example of application? Also which version of Python are we talking about? |
Ubuntu 20.04, system provided Python 3.8.2 in virtualenv Example application: https://github.com/zgoda/newsloop-server/tree/d603a1c10c9e8be3d998f62ccc55dd73f4677115 (with aiohttp) or https://github.com/zgoda/newsloop-server/tree/b2a8a7f09fa9848d0384b51a3f6c0bb037fb459e (with Sanic). Exact gunicorn invocation in my earlier comment. Differences in output between aiohttp and Sanic make me suspicious that there's something wrong involving workers. |
Same issue, python 3.8.0 Edit: this happens when i run locally on my Mac, but not when running inside a Linux docker, might help you |
Hello, |
Im experiencing this too, FastAPI + the latest Gunicorn and uvicorn workers with Python 3.8.5 As soon as I stop using uvicorn (i.e. remove this line from my gunicorn config): worker_class = "uvicorn.workers.UvicornWorker" The errors dissappear. As described above, this happens when stopping Gunicorn with Ctrl+C or sending a graceful kill signal to the PID.
|
Here's an exact replication of the issue:
And here's the
I attempted to install uvicorn and gunicorn from GitHub (master branch) to ensure I got the very latest fixes but the problem persisted. Hope this helps |
Evidence. In a new folder on osx run the attached script @benoitc, what do you think of this commit in file test.sh
file Dockerfile
|
I had exactly same issue. Here is my case. Brief : I'm trying to establish a test application for Django dwebsocket with gunicorn. When I trying to use websocket_client to test the result, after close the websocket this error happen everytime. Environment : Code: view.py
urls.py
websocket_client
commad to run gunicorn server
error output
|
@ChrisXiaoShu The stack trace you posted tells us that this specific socket object has been explicitly closed at the Python level (that's when gevent uses its |
Kind of the same problem in my case, with the difference that this error happens without doing anything. Sometimes after 5min, sometimes after 2hrs... |
benoitc/gunicorn#1877 (comment) Signed-off-by: Cédric Foellmi <cedric@onekiloparsec.dev>
had same issue on that setup: Docker image : python:3.7.10-slim-stretch |
I don’t know if the issue is still unresolved! I had a similar issue (FastAPI + uvicorn worker + gunicorn + supervisor). Gunicorn was unable to stop workers and I saw the above error in the log. I give the unique process name in the gunicorn settings |
Last time I had this error It was because of a print statement, it raises this error & kill the worker. Removing the print statement & replacing it with logging works. |
I was trying to tackle this issue, since it's happening to us every time Gunicorn terminates an |
A second approach would be logging it as |
Similar problem here, k8s, gunicorn with gevent, flask:
It sounds kind of like some people think this is a benign error that shouldn't be logged, but in our case it appears to be killing the worker - so not benign. |
This seems to be biting me as well running saleor API deployed with gunicorn + uvicorn worker. The commit from @onekiloparsec kind of makes sense but that commit branch is old enough that its not compatible with my other dependencies when I try to install it. Forking the uvicorn repo to try and cherry pick that commit into my running version to see if it helps. EDIT: Actually the 0.17.6 branch has the code already in the form of @onekiloparsec commit. I perhaps started seeing this only after adding Latest uvicorn logic:
|
@matteius if you confirm running smoothly for a few days with 0.17.6, I may reconsider going back to the main branch! |
i am not reproucingi t myself. closing the issue |
I use this FastAPI Docker image, and this error occurs every time I restart my services: https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker @benoitc Did you try to run the script that @gg349 posted above? #1877 (comment) I just tested that and it replicates the error. Just create the The Here is the relevant output which includes the error (fourth line from the bottom):
I think this issue should remain open. |
Still happening for me with FastAPI + Gunicorn + Uvicorn in Docker. |
@benoitc Maybe I can help you here... The problem here is that the Line 382 in 69c508a
The thing is that Lines 211 to 212 in 69c508a
This decision was made on #1310. At the time, #1309 was closed. Maybe it shouldn't have been... I'll merge encode/uvicorn#1710 on |
This also happens for me when using Uvicorn worker class. In my case, I run nginx and Gunicorn in a Docker container where nginx server proxies requests to UNIX socket bound by Gunicorn. Both nginx and Gunicorn are managed by Supervisor. I also define a file watch for my app's config file (using watchfiles) in Supervisor's configuration which sends HUP signal to Gunicorn upon a file change. According to the documentation, this should be used for a graceful reload. It works well but exhibits the error with closing the socket. Here's the components' version info:
Relevant part of
Relevant part of
Here's the Docker container log:
|
I also see this error on latest gunicorn+uvicorn every time max-requests triggers and reaps a worker. |
For us the problem was our form was doing a The trailing slash was resulting in a 307 redirect and... making the file not write? |
What is the solution to above issue? |
Gunicorn (20.1.0) + Uvicorn (0.22.0) -> same issue |
This happens for me, too.
|
Happens to me too :
|
@Aniket-Singla please upgrade to 21.2.0 this is fixing such issue. Thanks for the report, but next time can you open a new ticket or create a new one that link to a closed issue. This is described in the contributing document and helps me to track issues ) |
Thankyou so much for your reply and sorry for not reading the contributing Doc. Will upgrade |
It's a uvloop issue. Setting Uvicorn's loop to |
The same issue to me, but it's only occurred on my k8s deployment. |
The same for me with gunicorn == 21.2.0 and meinheld == 1.0.1. |
I'm getting this I'm running gunicorn in production with systemd. I periodically get And I checked memory, that's not it. |
can you explain more about this? my server is getting full of these logs |
So I just tried this and it did work for me. Here's a minimal example for FastAPI: I put this into
I use a
Now I no longer get file descriptor warnings. I'm using gunicorn 20.1.0, uvicorn 0.24.0.post1 and fastapi 0.108.0. |
I'm having this issue in raspbian image
[2018-09-10 20:40:11 +0800] [21421] [CRITICAL] WORKER TIMEOUT (pid:21699)
[2018-09-10 20:40:11 +0800] [21699] [ERROR] Socket error processing request.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gunicorn/workers/async.py", line 62, in handle
six.reraise(*sys.exc_info())
File "/usr/lib/python3/dist-packages/gunicorn/six.py", line 625, in reraise
raise value
File "/usr/lib/python3/dist-packages/gunicorn/workers/async.py", line 35, in handle
listener_name = listener.getsockname()
OSError: [Errno 9] Bad file descriptor
The text was updated successfully, but these errors were encountered: