Skip to content

Commit

Permalink
fcntl(fd, O_NONBLOCK) => os.set_blocking(fd, False)
Browse files Browse the repository at this point in the history
  • Loading branch information
pajod committed Aug 23, 2024
1 parent 708a391 commit c5b803c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- ubuntu-latest
# not defaulting to macos-latest: Python <= 3.9 was missing from macos-14 @ arm64
- macos-13
# Not testing Windows, because tests need Unix-only fcntl, grp, pwd, etc.
# Not testing Windows, because tests need Unix-only non-blocking pipes, grp, pwd, etc.
python-version:
# CPython <= 3.7 is EoL since 2023-06-27
- "3.7"
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ environment:
#- TOXENV: run-entrypoint
# PYTHON: "C:\\Python38-x64"
# Windows is not ready for testing!!!
# Python's fcntl, grp, pwd, os.geteuid(), and socket.AF_UNIX are all Unix-only.
# Python's non-blocking pipes, grp, pwd, os.geteuid(), and socket.AF_UNIX are all Unix-only.
#- TOXENV: py35
# PYTHON: "C:\\Python35-x64"
#- TOXENV: py36
Expand Down
7 changes: 4 additions & 3 deletions gunicorn/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ast
import email.utils
import errno
import fcntl
import html
import importlib
import inspect
Expand Down Expand Up @@ -258,8 +257,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):
Expand Down

0 comments on commit c5b803c

Please sign in to comment.