Skip to content

Commit

Permalink
test all workers
Browse files Browse the repository at this point in the history
  • Loading branch information
pajod committed May 6, 2024
1 parent 1481817 commit 0a0339c
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 71 deletions.
2 changes: 1 addition & 1 deletion gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def init_signals(self):
os.close(p)

# initialize the pipe
self.PIPE = pair = util.pipe2()
self.PIPE = util.pipe2()

self.log.close_on_exec()

Expand Down
2 changes: 2 additions & 0 deletions gunicorn/unix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import errno
import fcntl
import grp
import os
Expand All @@ -14,6 +15,7 @@ def resolve_gid(val):

def _assert_cloexec(fd):
# Python 3.4+: file descriptors created by Python non-inheritable by default
# .. but note that sysstemd may pass us LISTEN_FDS without such promise
fd_flags = fcntl.fcntl(fd, fcntl.F_GETFD)
# mind the difference between os.O_CLOEXEC and fcntl.FD_CLOEXEC
if not fd_flags | fcntl.FD_CLOEXEC:
Expand Down
4 changes: 2 additions & 2 deletions gunicorn/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from gunicorn.errors import AppImportError
from gunicorn.workers import SUPPORTED_WORKERS
if sys.platform.startswith("win"):
from gunicorn.windows import close_on_exec, pipe2, resolve_gid, resolve_uid, set_owner_process, matching_effective_uid_gid
from gunicorn.windows import * # pylint: disable=wildcard-import,unused-wildcard-import
else:
from gunicorn.unix import close_on_exec, pipe2, resolve_gid, resolve_uid, set_owner_process, matching_effective_uid_gid
from gunicorn.unix import * # pylint: disable=wildcard-import,unused-wildcard-import

import urllib.parse

Expand Down
1 change: 0 additions & 1 deletion gunicorn/util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class _SplitURL(NamedTuple):
fragment: str

def _setproctitle(title: str) -> None: ...
def better_dependency_error(package_name: str) -> None: ...
def get_arity(f: typing.Callable[..., None]) -> int: ...
def get_username(uid: int) -> str: ...
def chown(path: str | PathLike[str], uid: int, gid: int) -> None: ...
Expand Down
26 changes: 21 additions & 5 deletions gunicorn/windows.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
# no implementation here
# .. providing this file allows importing module on unsupported platforms.


class Unsupported(RuntimeError):
pass


def matching_effective_uid_gid(uid, gid):
if uid is None and gid is None:
return True
raise Unsupported("geteuid() unsupported on this platform. Have your service manager setup user/group instead.")
raise Unsupported(
"geteuid() unsupported on this platform. "
"Have your service manager setup user/group instead."
)


def resolve_uid(val):
raise Unsupported("setuid() unsupported on this platform. Have your service manager setup user/group instead.")
raise Unsupported(
"setuid() unsupported on this platform. "
"Have your service manager setup user/group instead."
)


def resolve_gid(val):
raise Unsupported("setgid() unsupported on this platform. Have your service manager setup user/group instead.")
raise Unsupported(
"setgid() unsupported on this platform. "
"Have your service manager setup user/group instead."
)


def close_on_exec(fd):
Expand All @@ -36,9 +46,15 @@ def set_owner_process(uid, gid, initgroups=False):
"""set user and group of workers processes"""

if gid is not None:
raise Unsupported("setgid() unsupported on this platform. Have your service manager setup user/group instead.")
raise Unsupported(
"setgid() unsupported on this platform. "
"Have your service manager setup user/group instead."
)
if uid is not None:
raise Unsupported("setuid() unsupported on this platform. Have your service manager setup user/group instead.")
raise Unsupported(
"setuid() unsupported on this platform. "
"Have your service manager setup user/group instead."
)


ALL = [
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ main = "gunicorn.app.pasterapp:serve"
# # can override these: python -m pytest --override-ini="addopts="
norecursedirs = ["examples", "lib", "local", "src"]
testpaths = ["tests/"]
addopts = "--assert=plain"
addopts = ["--strict-markers", "--assert=plain"]
xfail-strict = true

[tool.setuptools]
zip-safe = false
Expand Down
Loading

0 comments on commit 0a0339c

Please sign in to comment.