Skip to content
Open
72 changes: 72 additions & 0 deletions .github/workflows/bsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: bsd
on:
push:
branches:
- master
paths:
- '*.py'
- 'tox.ini'
- '.github/workflows/bsd.yml'
pull_request:
branches:
- master
workflow_dispatch:
# allow manual trigger
permissions:
# BOLD WARNING: do not add permissions, this workflow executes remote code
contents: read
env:
FORCE_COLOR: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
freebsd:
name: freebsd
timeout-minutes: 20
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: vmactions/freebsd-vm@v1
with:
# TODO: replace pyMN with version-agnostic alias
prepare: pkg install -y nginx python311 py311-pip py311-tox py311-sqlite3
usesh: true
copyback: false
# not a typo: "openssl --version" != "openssl version"
run: |
uname -a \
&& python3.11 --version \
&& python3.11 -c 'import os,sys,platform;print(platform.system(),sys.platform,os.name)' \
&& python3.11 -m tox --version \
&& openssl version \
&& pkg info nginx \
&& python3.11 -m tox -e run-module \
&& python3.11 -m tox -e run-entrypoint \
&& python3.11 -m tox -e py

openbsd:
name: openbsd
timeout-minutes: 20
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: vmactions/openbsd-vm@v1
with:
prepare: pkg_add python py3-pip py3-tox py3-sqlite3 nginx
usesh: true
copyback: false
run: |
uname -a \
&& python3 --version \
&& python3 -c 'import os,sys,platform;print(platform.system(),sys.platform,os.name)' \
&& python3 -m tox --version \
&& openssl version \
&& pkg_info nginx \
&& python3 -m tox -e run-module \
&& python3 -m tox -e run-entrypoint \
&& python3 -m tox -e py
59 changes: 59 additions & 0 deletions .github/workflows/illumos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: illumos
on:
push:
branches:
- master
paths:
- '*.py'
- 'tox.ini'
- '.github/workflows/illumos.yml'
pull_request:
branches:
- master
workflow_dispatch:
# allow manual trigger
permissions:
# BOLD WARNING: do not add permissions, this workflow executes remote code
contents: read
env:
FORCE_COLOR: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
omnios:
name: illumos
timeout-minutes: 20
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: vmactions/omnios-vm@v1
with:
# need gcc: compile greenlet from source
# autoconf must pretend inotify unavail: libev FTBFS
# /tmp/.nginx must exist because nginx will not create configured tmp
# build-essential shall point to suitable gcc13/gcc14/..
# TODO: replace python-MN with version-agnostic alias
# pinning below r151050 to avoid gcc14 incompat
release: "r151050"
prepare: |
pkg install pip-312 python-312 sqlite-3 nginx gcc13
usesh: true
copyback: false
run: |
cat /etc/release \
&& uname -a \
&& python3 --version \
&& python3 -c 'import os,sys,platform;print(platform.system(),sys.platform,os.name)' \
&& openssl version \
&& pkg info nginx \
&& gcc -dM -E - </dev/null \
&& ac_cv_header_sys_inotify_h=no ac_cv_func_inotify_init=no python3 -m pip install 'gevent!=24.10.1,!=24.10.2,!=24.10.3,!=24.11.1' \
&& mkdir -p /tmp/.nginx \
&& python3 -m pip install tox \
&& python3 -m tox --version \
&& python3 -m tox -e run-module \
&& python3 -m tox -e run-entrypoint \
&& python3 -m tox -e py
17 changes: 15 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
name: tox
on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
# allow manual trigger
permissions:
contents: read # to fetch code (actions/checkout)
env:
Expand All @@ -19,7 +27,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 Expand Up @@ -54,6 +62,11 @@ jobs:
cache-dependency-path: requirements_test.txt
check-latest: true
allow-prereleases: ${{ matrix.unsupported }}
- name: Add test utils
if: matrix.os == 'ubuntu-latest'
run: |
sudo systemctl mask nginx.service
sudo apt install nginx openssl wrk
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
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
14 changes: 8 additions & 6 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 @@ -251,14 +250,17 @@ def parse_address(netloc, default_port='8000'):


def close_on_exec(fd):
flags = fcntl.fcntl(fd, fcntl.F_GETFD)
flags |= fcntl.FD_CLOEXEC
fcntl.fcntl(fd, fcntl.F_SETFD, flags)
# available since Python 3.4, equivalent to either:
# ioctl(fd, FIOCLEX)
# fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC)
os.set_inheritable(fd, False)


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
2 changes: 1 addition & 1 deletion gunicorn/workers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def init_process(self):

# Prevent fd inheritance
for s in self.sockets:
util.close_on_exec(s)
util.close_on_exec(s.fileno())
util.close_on_exec(self.tmp.fileno())

self.wait_fds = self.sockets + [self.PIPE[0]]
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/workers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SyncWorker(base.Worker):
def accept(self, listener):
client, addr = listener.accept()
client.setblocking(1)
util.close_on_exec(client)
util.close_on_exec(client.fileno())
self.handle(listener, client, addr)

def wait(self, timeout):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ tornado = ["tornado>=0.2"]
gthread = []
setproctitle = ["setproctitle"]
testing = [
"gevent!=24.10.1,!=24.10.2,!=24.10.3,!=24.11.1;sys_platform=='sunos5'",
"gevent",
"eventlet",
"coverage",
Expand Down
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gevent!=24.10.1,!=24.10.2,!=24.10.3,!=24.11.1;sys_platform=='sunos5'
gevent
eventlet
coverage
Expand Down
Loading