Skip to content

Commit 11ff7e1

Browse files
authored
[gunicorn] Update to 25.0.* (#15363)
1 parent e79e6af commit 11ff7e1

26 files changed

+828
-27
lines changed

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"stubs/grpcio-reflection/grpc_reflection/v1alpha",
4545
"stubs/grpcio-status/grpc_status",
4646
"stubs/grpcio/grpc/__init__.pyi",
47+
"stubs/gunicorn/gunicorn/dirty",
4748
"stubs/hdbcli/hdbcli/dbapi.pyi",
4849
"stubs/html5lib",
4950
"stubs/httplib2",

stubs/gunicorn/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "24.1.*"
1+
version = "25.0.*"
22
upstream_repository = "https://github.com/benoitc/gunicorn"
33
requires = ["types-gevent"]
44

stubs/gunicorn/gunicorn/arbiter.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from typing import ClassVar
44

55
from gunicorn.app.base import BaseApplication
66
from gunicorn.config import Config
7+
from gunicorn.dirty import DirtyArbiter
78
from gunicorn.glogging import Logger as GLogger
89
from gunicorn.sock import BaseSocket
910
from gunicorn.workers.base import Worker
@@ -28,6 +29,9 @@ class Arbiter:
2829
reexec_pid: int
2930
master_pid: int
3031
master_name: str
32+
dirty_arbiter_pid: int
33+
dirty_arbiter: DirtyArbiter | None
34+
dirty_pidfile: str | None
3135
pid: int
3236
app: BaseApplication
3337
cfg: Config
@@ -69,3 +73,7 @@ class Arbiter:
6973
def spawn_workers(self) -> None: ...
7074
def kill_workers(self, sig: int) -> None: ...
7175
def kill_worker(self, pid: int, sig: int) -> None: ...
76+
def spawn_dirty_arbiter(self) -> int | None: ...
77+
def kill_dirty_arbiter(self, sig: int) -> None: ...
78+
def reap_dirty_arbiter(self) -> None: ...
79+
def manage_dirty_arbiter(self) -> None: ...

stubs/gunicorn/gunicorn/asgi/message.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ class AsyncRequest:
4545
async def parse(cls, cfg: Config, unreader: AsyncUnreader, peer_addr: _AddressType, req_number: int = 1) -> Self: ...
4646
def force_close(self) -> None: ...
4747
def should_close(self) -> bool: ...
48-
def get_header(self, name: str) -> str: ...
48+
def get_header(self, name: str) -> str | None: ...
4949
async def read_body(self, size: int = 8192) -> bytes: ...
5050
async def drain_body(self) -> None: ...
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from typing import Literal
2+
from typing_extensions import Self
3+
4+
from gunicorn.asgi.unreader import AsyncUnreader
5+
from gunicorn.config import Config
6+
from gunicorn.uwsgi.message import UWSGIRequest
7+
8+
from .._types import _AddressType
9+
10+
class AsyncUWSGIRequest(UWSGIRequest):
11+
cfg: Config
12+
unreader: AsyncUnreader # type: ignore[assignment]
13+
peer_addr: _AddressType
14+
remote_addr: _AddressType
15+
req_number: int
16+
method: str | None
17+
uri: str | None
18+
path: str | None
19+
query: str | None
20+
fragment: str | None
21+
version: tuple[int, int]
22+
headers: list[tuple[str, str]]
23+
trailers: list[tuple[str, str]]
24+
scheme: Literal["https", "http"]
25+
must_close: bool
26+
uwsgi_vars: dict[str, str]
27+
modifier1: int
28+
modifier2: int
29+
proxy_protocol_info: dict[str, str | int | None] | None # TODO: Use TypedDict
30+
content_length: int
31+
chunked: bool
32+
33+
def __init__(self, cfg: Config, unreader: AsyncUnreader, peer_addr: _AddressType, req_number: int = 1) -> None: ...
34+
@classmethod
35+
async def parse(cls, cfg: Config, unreader: AsyncUnreader, peer_addr: _AddressType, req_number: int = 1) -> Self: ... # type: ignore[override]
36+
async def read_body(self, size: int = 8192) -> bytes: ...
37+
async def drain_body(self) -> None: ...
38+
def get_header(self, name: str) -> str | None: ...

stubs/gunicorn/gunicorn/config.pyi

Lines changed: 162 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import argparse
22
from _typeshed import ConvertibleToInt
33
from collections.abc import Callable, Container
44
from ssl import SSLContext, _SSLMethod
5-
from typing import Annotated, Any, ClassVar, overload
5+
from typing import Annotated, Any, ClassVar, Final, overload
66
from typing_extensions import TypeAlias
77

88
from gunicorn.arbiter import Arbiter
@@ -34,6 +34,10 @@ _WorkerExitHookType: TypeAlias = Callable[[Arbiter, Worker], object]
3434
_NumWorkersChangedHookType: TypeAlias = Callable[[Arbiter, int, int | None], object]
3535
_OnExitHookType: TypeAlias = Callable[[Arbiter], object]
3636
_SSLContextHookType: TypeAlias = Callable[[Config, Callable[[], SSLContext]], SSLContext]
37+
_OnDirtyStartingHookType: TypeAlias = Callable[[Arbiter], object]
38+
_DirtyPostForkHookType: TypeAlias = Callable[[Arbiter, Worker], object]
39+
_DirtyWorkerInitHookType: TypeAlias = Callable[[Worker], object]
40+
_DirtyWorkerExitHookType: TypeAlias = Callable[[Arbiter, Worker], object]
3741

3842
_HookType: TypeAlias = (
3943
_OnStartingHookType
@@ -52,12 +56,16 @@ _HookType: TypeAlias = (
5256
| _NumWorkersChangedHookType
5357
| _OnExitHookType
5458
| _SSLContextHookType
59+
| _OnDirtyStartingHookType
60+
| _DirtyPostForkHookType
61+
| _DirtyWorkerInitHookType
62+
| _DirtyWorkerExitHookType
5563
)
5664
# Validators
5765
_BoolValidatorType: TypeAlias = Callable[[bool | str | None], bool | None]
5866
_StringValidatorType: TypeAlias = Callable[[str | None], str | None]
5967
_ListStringValidatorType: TypeAlias = Callable[[str | list[str] | None], list[str]]
60-
_IntValidatorType: TypeAlias = Callable[[int | ConvertibleToInt], int]
68+
_IntValidatorType: TypeAlias = Callable[[ConvertibleToInt], int]
6169
_DictValidatorType: TypeAlias = Callable[[dict[str, Any]], dict[str, Any]]
6270
_ClassValidatorType: TypeAlias = Callable[[object | str | None], type[Any] | None]
6371
_UserGroupValidatorType: TypeAlias = Callable[[str | int | None], int]
@@ -66,6 +74,8 @@ _CallableValidatorType: TypeAlias = Callable[[str | _HookType], _HookType]
6674
_ProxyProtocolValidatorType: TypeAlias = Callable[[str | bool | None], str]
6775
_ASGILoopValidatorType: TypeAlias = Callable[[str | None], str]
6876
_ASGILifespanValidatorType: TypeAlias = Callable[[str | None], str]
77+
_HTTP2FrameSizeValidatorType: TypeAlias = Callable[[ConvertibleToInt], int]
78+
_HTTPProtocolsValidatorType: TypeAlias = Callable[[str | None], list[str]]
6979

7080
_ValidatorType: TypeAlias = ( # noqa: Y047
7181
_BoolValidatorType
@@ -80,6 +90,8 @@ _ValidatorType: TypeAlias = ( # noqa: Y047
8090
| _ProxyProtocolValidatorType
8191
| _ASGILoopValidatorType
8292
| _ASGILifespanValidatorType
93+
| _HTTP2FrameSizeValidatorType
94+
| _HTTPProtocolsValidatorType
8395
)
8496

8597
KNOWN_SETTINGS: list[Setting]
@@ -163,10 +175,8 @@ def validate_bool(val: None) -> None: ...
163175
@overload
164176
def validate_bool(val: Annotated[str, "Case-insensitive boolean string ('true'/'false' in any case)"]) -> bool: ...
165177
def validate_dict(val: dict[str, Any]) -> dict[str, Any]: ...
166-
@overload
167-
def validate_pos_int(val: int) -> int: ...
168-
@overload
169178
def validate_pos_int(val: ConvertibleToInt) -> int: ...
179+
def validate_http2_frame_size(val: ConvertibleToInt) -> int: ...
170180
def validate_ssl_version(val: _SSLMethod) -> _SSLMethod: ...
171181
@overload
172182
def validate_string(val: str) -> str: ...
@@ -176,18 +186,8 @@ def validate_string(val: None) -> None: ...
176186
def validate_file_exists(val: str) -> str: ...
177187
@overload
178188
def validate_file_exists(val: None) -> None: ...
179-
@overload
180-
def validate_list_string(val: str) -> list[str]: ...
181-
@overload
182-
def validate_list_string(val: list[str]) -> list[str]: ...
183-
@overload
184-
def validate_list_string(val: None) -> list[str]: ...
185-
@overload
186-
def validate_list_of_existing_files(val: str) -> list[str]: ...
187-
@overload
188-
def validate_list_of_existing_files(val: list[str]) -> list[str]: ...
189-
@overload
190-
def validate_list_of_existing_files(val: None) -> list[str]: ...
189+
def validate_list_string(val: str | list[str] | None) -> list[str]: ...
190+
def validate_list_of_existing_files(val: str | list[str] | None) -> list[str]: ...
191191
def validate_string_to_addr_list(val: str | None) -> list[str]: ...
192192
def validate_string_to_list(val: str | None) -> list[str]: ...
193193
@overload
@@ -766,7 +766,7 @@ class Paste(Setting):
766766
class OnStarting(Setting):
767767
name: ClassVar[str]
768768
section: ClassVar[str]
769-
validator: ClassVar[_CallableValidatorType] = ...
769+
validator: ClassVar[_CallableValidatorType]
770770
type: ClassVar[Callable[..., Any]]
771771
default: ClassVar[_OnStartingHookType]
772772
desc: ClassVar[str]
@@ -1029,6 +1029,60 @@ class Ciphers(Setting):
10291029
default: ClassVar[None]
10301030
desc: ClassVar[str]
10311031

1032+
VALID_HTTP_PROTOCOLS: Final[frozenset[str]]
1033+
ALPN_PROTOCOL_MAP: Final[dict[str, str]]
1034+
1035+
def validate_http_protocols(val: str | None) -> list[str]: ...
1036+
1037+
class HTTPProtocols(Setting):
1038+
name: ClassVar[str]
1039+
section: ClassVar[str]
1040+
cli: ClassVar[list[str]]
1041+
meta: ClassVar[str]
1042+
validator: ClassVar[_HTTPProtocolsValidatorType]
1043+
default: ClassVar[str]
1044+
desc: ClassVar[str]
1045+
1046+
class HTTP2MaxConcurrentStreams(Setting):
1047+
name: ClassVar[str]
1048+
section: ClassVar[str]
1049+
cli: ClassVar[list[str]]
1050+
meta: ClassVar[str]
1051+
validator: ClassVar[_IntValidatorType]
1052+
type: ClassVar[type[int]]
1053+
default: ClassVar[int]
1054+
desc: ClassVar[str]
1055+
1056+
class HTTP2InitialWindowSize(Setting):
1057+
name: ClassVar[str]
1058+
section: ClassVar[str]
1059+
cli: ClassVar[list[str]]
1060+
meta: ClassVar[str]
1061+
validator: ClassVar[_IntValidatorType]
1062+
type: ClassVar[type[int]]
1063+
default: ClassVar[int]
1064+
desc: ClassVar[str]
1065+
1066+
class HTTP2MaxFrameSize(Setting):
1067+
name: ClassVar[str]
1068+
section: ClassVar[str]
1069+
cli: ClassVar[list[str]]
1070+
meta: ClassVar[str]
1071+
validator: ClassVar[_HTTP2FrameSizeValidatorType]
1072+
type: ClassVar[type[int]]
1073+
default: ClassVar[int]
1074+
desc: ClassVar[str]
1075+
1076+
class HTTP2MaxHeaderListSize(Setting):
1077+
name: ClassVar[str]
1078+
section: ClassVar[str]
1079+
cli: ClassVar[list[str]]
1080+
meta: ClassVar[str]
1081+
validator: ClassVar[_IntValidatorType]
1082+
type: ClassVar[type[int]]
1083+
default: ClassVar[int]
1084+
desc: ClassVar[str]
1085+
10321086
class PasteGlobalConf(Setting):
10331087
name: ClassVar[str]
10341088
action: ClassVar[str]
@@ -1129,3 +1183,93 @@ class RootPath(Setting):
11291183
validator: ClassVar[_StringValidatorType]
11301184
default: ClassVar[str]
11311185
desc: ClassVar[str]
1186+
1187+
class DirtyApps(Setting):
1188+
name: ClassVar[str]
1189+
section: ClassVar[str]
1190+
cli: ClassVar[list[str]]
1191+
action: ClassVar[str]
1192+
meta: ClassVar[str]
1193+
validator: ClassVar[_ListStringValidatorType]
1194+
default: ClassVar[list[str]]
1195+
desc: ClassVar[str]
1196+
1197+
class DirtyWorkers(Setting):
1198+
name: ClassVar[str]
1199+
section: ClassVar[str]
1200+
cli: ClassVar[list[str]]
1201+
meta: ClassVar[str]
1202+
validator: ClassVar[_IntValidatorType]
1203+
type: ClassVar[type[int]]
1204+
default: ClassVar[int]
1205+
desc: ClassVar[str]
1206+
1207+
class DirtyTimeout(Setting):
1208+
name: ClassVar[str]
1209+
section: ClassVar[str]
1210+
cli: ClassVar[list[str]]
1211+
meta: ClassVar[str]
1212+
validator: ClassVar[_IntValidatorType]
1213+
type: ClassVar[type[int]]
1214+
default: ClassVar[int]
1215+
desc: ClassVar[str]
1216+
1217+
class DirtyThreads(Setting):
1218+
name: ClassVar[str]
1219+
section: ClassVar[str]
1220+
cli: ClassVar[list[str]]
1221+
meta: ClassVar[str]
1222+
validator: ClassVar[_IntValidatorType]
1223+
type: ClassVar[type[int]]
1224+
default: ClassVar[int]
1225+
desc: ClassVar[str]
1226+
1227+
class DirtyGracefulTimeout(Setting):
1228+
name: ClassVar[str]
1229+
section: ClassVar[str]
1230+
cli: ClassVar[list[str]]
1231+
meta: ClassVar[str]
1232+
validator: ClassVar[_IntValidatorType]
1233+
type: ClassVar[type[int]]
1234+
default: ClassVar[int]
1235+
desc: ClassVar[str]
1236+
1237+
class OnDirtyStarting(Setting):
1238+
name: ClassVar[str]
1239+
section: ClassVar[str]
1240+
validator: ClassVar[_CallableValidatorType]
1241+
type: ClassVar[Callable[..., Any]]
1242+
default: ClassVar[_OnDirtyStartingHookType]
1243+
desc: ClassVar[str]
1244+
1245+
def on_dirty_starting(arbiter: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
1246+
1247+
class DirtyPostFork(Setting):
1248+
name: ClassVar[str]
1249+
section: ClassVar[str]
1250+
validator: ClassVar[_CallableValidatorType]
1251+
type: ClassVar[Callable[..., Any]]
1252+
default: ClassVar[_DirtyPostForkHookType]
1253+
desc: ClassVar[str]
1254+
1255+
def dirty_post_fork(arbiter: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
1256+
1257+
class DirtyWorkerInit(Setting):
1258+
name: ClassVar[str]
1259+
section: ClassVar[str]
1260+
validator: ClassVar[_CallableValidatorType]
1261+
type: ClassVar[Callable[..., Any]]
1262+
default: ClassVar[_DirtyWorkerInitHookType]
1263+
desc: ClassVar[str]
1264+
1265+
def dirty_worker_init(worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
1266+
1267+
class DirtyWorkerExit(Setting):
1268+
name: ClassVar[str]
1269+
section: ClassVar[str]
1270+
validator: ClassVar[_CallableValidatorType]
1271+
type: ClassVar[Callable[..., Any]]
1272+
default: ClassVar[_DirtyWorkerExitHookType]
1273+
desc: ClassVar[str]
1274+
1275+
def dirty_worker_exit(arbiter: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from .app import DirtyApp as DirtyApp
2+
from .arbiter import DirtyArbiter as DirtyArbiter
3+
from .client import (
4+
DirtyClient as DirtyClient,
5+
close_dirty_client as close_dirty_client,
6+
close_dirty_client_async as close_dirty_client_async,
7+
get_dirty_client as get_dirty_client,
8+
get_dirty_client_async as get_dirty_client_async,
9+
set_dirty_socket_path as set_dirty_socket_path,
10+
)
11+
from .errors import (
12+
DirtyAppError as DirtyAppError,
13+
DirtyAppNotFoundError as DirtyAppNotFoundError,
14+
DirtyConnectionError as DirtyConnectionError,
15+
DirtyError as DirtyError,
16+
DirtyProtocolError as DirtyProtocolError,
17+
DirtyTimeoutError as DirtyTimeoutError,
18+
DirtyWorkerError as DirtyWorkerError,
19+
)
20+
21+
__all__ = [
22+
"DirtyError",
23+
"DirtyTimeoutError",
24+
"DirtyConnectionError",
25+
"DirtyWorkerError",
26+
"DirtyAppError",
27+
"DirtyAppNotFoundError",
28+
"DirtyProtocolError",
29+
"DirtyApp",
30+
"DirtyClient",
31+
"get_dirty_client",
32+
"get_dirty_client_async",
33+
"close_dirty_client",
34+
"close_dirty_client_async",
35+
"DirtyArbiter",
36+
"set_dirty_socket_path",
37+
]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from _typeshed import Incomplete
2+
from collections.abc import Iterable
3+
from typing import Any
4+
5+
class DirtyApp:
6+
workers: Incomplete | None
7+
8+
def init(self) -> None: ...
9+
def __call__(
10+
self, action: str, *args: Any, **kwargs: Any
11+
) -> Any: ... # Arguments and result depend on method name passed to action
12+
def close(self) -> None: ...
13+
14+
def parse_dirty_app_spec(spec: str) -> tuple[str, int | None]: ...
15+
def load_dirty_app(import_path: str): ...
16+
def load_dirty_apps(import_paths: Iterable[str]) -> dict[str, Incomplete]: ...
17+
def get_app_workers_attribute(import_path: str) -> int | None: ...

0 commit comments

Comments
 (0)