From efe2c6f1ba7a558eb65e27b63d5116fb22392a85 Mon Sep 17 00:00:00 2001 From: "Paul J. Dorn" Date: Sun, 12 May 2024 23:54:38 +0200 Subject: [PATCH] fcntl(fd, O_NONBLOCK) => os.set_blocking(fd, False) --- gunicorn/util.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gunicorn/util.py b/gunicorn/util.py index 1c2e71d8f..b294d0bc7 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -5,7 +5,6 @@ import ast import email.utils import errno -import fcntl import html import importlib import inspect @@ -263,8 +262,10 @@ def close_on_exec(fd): def set_non_blocking(fd): - flags = fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK - fcntl.fcntl(fd, fcntl.F_SETFL, flags) + # available since Python 3.5, equivalent to either: + # ioctl(fd, FIONBIO) + # fcntl(fd, fcntl.F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) + os.set_blocking(fd, False) def close(sock):