Update upstream source from tag 'upstream/20.0.4'
Update to upstream version '20.0.4'
with Debian dir 3a682ad0fd06219121c19b07faae31e7fbd49757
Chris Lamb
4 years ago
15 | 15 | <div class="logo-div"> |
16 | 16 | <div class="latest"> |
17 | 17 | Latest version: <strong><a |
18 | href="https://docs.gunicorn.org/en/stable/">20.0.1</a></strong> | |
18 | href="https://docs.gunicorn.org/en/stable/">20.0.3</a></strong> | |
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class="logo"><img src="images/logo.jpg" ></div> |
50 | 50 | Configuration File |
51 | 51 | ================== |
52 | 52 | |
53 | The configuration file should be a valid Python source file. It only needs to | |
54 | be readable from the file system. More specifically, it does not need to be | |
55 | importable. Any Python is valid. Just consider that this will be run every time | |
56 | you start Gunicorn (including when you signal Gunicorn to reload). | |
53 | The configuration file should be a valid Python source file with a **python | |
54 | extension** (e.g. `gunicorn.conf.py`). It only needs to be readable from the | |
55 | file system. More specifically, it does not have to be on the module path | |
56 | (sys.path, PYTHONPATH). Any Python is valid. Just consider that this will be | |
57 | run every time you start Gunicorn (including when you signal Gunicorn to reload). | |
57 | 58 | |
58 | 59 | To set a parameter, just assign to it. There's no special syntax. The values |
59 | 60 | you provide will be used for the configuration values. |
0 | 0 | ========= |
1 | 1 | Changelog |
2 | 2 | ========= |
3 | ||
4 | 20.0.4 / 2019/11/26 | |
5 | =================== | |
6 | ||
7 | - fix binding a socket using the file descriptor | |
8 | - remove support for the `bdist_rpm` build | |
9 | ||
10 | 20.0.3 / 2019/11/24 | |
11 | =================== | |
12 | ||
13 | - fixed load of a config file without a Python extension | |
14 | - fixed `socketfromfd.fromfd` when defaults are not set | |
15 | ||
16 | .. note:: we now warn when we load a config file without Python Extension | |
3 | 17 | |
4 | 18 | 20.0.2 / 2019/11/23 |
5 | 19 | =================== |
2 | 2 | # This file is part of gunicorn released under the MIT license. |
3 | 3 | # See the NOTICE for more information. |
4 | 4 | |
5 | version_info = (20, 0, 2) | |
5 | version_info = (20, 0, 4) | |
6 | 6 | __version__ = ".".join([str(v) for v in version_info]) |
7 | 7 | SERVER_SOFTWARE = "gunicorn/%s" % __version__ |
2 | 2 | # This file is part of gunicorn released under the MIT license. |
3 | 3 | # See the NOTICE for more information. |
4 | 4 | import importlib.util |
5 | import importlib.machinery | |
5 | 6 | import os |
6 | 7 | import sys |
7 | 8 | import traceback |
93 | 94 | if not os.path.exists(filename): |
94 | 95 | raise RuntimeError("%r doesn't exist" % filename) |
95 | 96 | |
97 | ext = os.path.splitext(filename)[1] | |
98 | ||
96 | 99 | try: |
97 | 100 | module_name = '__config__' |
98 | spec = importlib.util.spec_from_file_location(module_name, filename) | |
101 | if ext in [".py", ".pyc"]: | |
102 | spec = importlib.util.spec_from_file_location(module_name, filename) | |
103 | else: | |
104 | msg = "configuration file should have a valid Python extension.\n" | |
105 | util.warn(msg) | |
106 | loader_ = importlib.machinery.SourceFileLoader(module_name, filename) | |
107 | spec = importlib.util.spec_from_file_location(module_name, filename, loader=loader_) | |
99 | 108 | mod = importlib.util.module_from_spec(spec) |
100 | 109 | sys.modules[module_name] = mod |
101 | 110 | spec.loader.exec_module(mod) |
10 | 10 | import time |
11 | 11 | |
12 | 12 | from gunicorn import util |
13 | from gunicorn.socketfromfd import fromfd | |
14 | 13 | |
15 | 14 | |
16 | 15 | class BaseSocket(object): |
167 | 166 | # sockets are already bound |
168 | 167 | if fdaddr: |
169 | 168 | for fd in fdaddr: |
170 | sock = fromfd(fd) | |
169 | sock = socket.fromfd(fd, socket.AF_UNIX, socket.SOCK_STREAM) | |
171 | 170 | sock_name = sock.getsockname() |
172 | 171 | sock_type = _sock_type(sock_name) |
173 | 172 | listener = sock_type(sock_name, conf, log, fd=fd) |
0 | # Copyright (C) 2016 Christian Heimes | |
1 | """socketfromfd -- socket.fromd() with auto-discovery | |
2 | ||
3 | ATTENTION: Do not remove this backport till the minimum required version is | |
4 | Python 3.7. See https://bugs.python.org/issue28134 for details. | |
5 | """ | |
6 | from __future__ import print_function | |
7 | ||
8 | import ctypes | |
9 | import os | |
10 | import socket | |
11 | import sys | |
12 | import platform | |
13 | ||
14 | from .util import find_library | |
15 | ||
16 | __all__ = ('fromfd',) | |
17 | ||
18 | SO_DOMAIN = getattr(socket, 'SO_DOMAIN', 39) | |
19 | SO_TYPE = getattr(socket, 'SO_TYPE', 3) | |
20 | SO_PROTOCOL = getattr(socket, 'SO_PROTOCOL', 38) | |
21 | ||
22 | _libc_name = find_library('c') | |
23 | if _libc_name is not None: | |
24 | if sys.platform.startswith("aix"): | |
25 | member = ( | |
26 | '(shr_64.o)' if ctypes.sizeof(ctypes.c_voidp) == 8 else '(shr.o)') | |
27 | # 0x00040000 correspondes to RTLD_MEMBER, undefined in Python <= 3.6 | |
28 | dlopen_mode = (ctypes.DEFAULT_MODE | 0x00040000 | os.RTLD_NOW) | |
29 | libc = ctypes.CDLL(_libc_name+member, | |
30 | use_errno=True, | |
31 | mode=dlopen_mode) | |
32 | else: | |
33 | libc = ctypes.CDLL(_libc_name, use_errno=True) | |
34 | else: | |
35 | raise OSError('libc not found') | |
36 | ||
37 | ||
38 | def _errcheck_errno(result, func, arguments): | |
39 | """Raise OSError by errno for -1 | |
40 | """ | |
41 | if result == -1: | |
42 | errno = ctypes.get_errno() | |
43 | raise OSError(errno, os.strerror(errno)) | |
44 | return arguments | |
45 | ||
46 | ||
47 | if platform.system() == 'SunOS': | |
48 | _libc_getsockopt = libc._so_getsockopt | |
49 | else: | |
50 | _libc_getsockopt = libc.getsockopt | |
51 | _libc_getsockopt.argtypes = [ | |
52 | ctypes.c_int, # int sockfd | |
53 | ctypes.c_int, # int level | |
54 | ctypes.c_int, # int optname | |
55 | ctypes.c_void_p, # void *optval | |
56 | ctypes.POINTER(ctypes.c_uint32) # socklen_t *optlen | |
57 | ] | |
58 | _libc_getsockopt.restype = ctypes.c_int # 0: ok, -1: err | |
59 | _libc_getsockopt.errcheck = _errcheck_errno | |
60 | ||
61 | ||
62 | def _raw_getsockopt(fd, level, optname): | |
63 | """Make raw getsockopt() call for int32 optval | |
64 | ||
65 | :param fd: socket fd | |
66 | :param level: SOL_* | |
67 | :param optname: SO_* | |
68 | :return: value as int | |
69 | """ | |
70 | optval = ctypes.c_int(0) | |
71 | optlen = ctypes.c_uint32(4) | |
72 | _libc_getsockopt(fd, level, optname, | |
73 | ctypes.byref(optval), ctypes.byref(optlen)) | |
74 | return optval.value | |
75 | ||
76 | ||
77 | def fromfd(fd, keep_fd=True): | |
78 | """Create a socket from a file descriptor | |
79 | ||
80 | socket domain (family), type and protocol are auto-detected. By default | |
81 | the socket uses a dup()ed fd. The original fd can be closed. | |
82 | ||
83 | The parameter `keep_fd` influences fd duplication. Under Python 2 the | |
84 | fd is still duplicated but the input fd is closed. Under Python 3 and | |
85 | with `keep_fd=True`, the new socket object uses the same fd. | |
86 | ||
87 | :param fd: socket fd | |
88 | :type fd: int | |
89 | :param keep_fd: keep input fd | |
90 | :type keep_fd: bool | |
91 | :return: socket.socket instance | |
92 | :raises OSError: for invalid socket fd | |
93 | """ | |
94 | family = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_DOMAIN) | |
95 | typ = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_TYPE) | |
96 | proto = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_PROTOCOL) | |
97 | if sys.version_info.major == 2: | |
98 | # Python 2 has no fileno argument and always duplicates the fd | |
99 | sockobj = socket.fromfd(fd, family, typ, proto) | |
100 | sock = socket.socket(None, None, None, _sock=sockobj) | |
101 | if not keep_fd: | |
102 | os.close(fd) | |
103 | return sock | |
104 | else: | |
105 | if keep_fd: | |
106 | return socket.fromfd(fd, family, typ, proto) | |
107 | else: | |
108 | return socket.socket(family, typ, proto, fileno=fd) |
0 | %{__python} setup.py install --skip-build --root=$RPM_BUILD_ROOT | |
1 | ||
2 | # Build the HTML documentation using the default theme. | |
3 | %{__python} setup.py build_sphinx | |
4 | ||
5 | %if ! (0%{?fedora} > 12 || 0%{?rhel} > 5) | |
6 | %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} | |
7 | %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} | |
8 | %endif | |
9 | ||
10 | INSTALLED_FILES="\ | |
11 | %{python_sitelib}/* | |
12 | %{_bindir}/* | |
13 | %doc LICENSE NOTICE README.rst THANKS build/sphinx/html examples/example_config.py | |
14 | " | |
15 | echo "$INSTALLED_FILES" > INSTALLED_FILES |