Skip to content

Commit 1093349

Browse files
authored
[gunicorn] Update to 24.1.0 (#15323)
1 parent f424458 commit 1093349

29 files changed

+455
-51
lines changed

stubs/gunicorn/METADATA.toml

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
version_info: tuple[int, int, int]
2-
__version__: str
3-
SERVER: str
4-
SERVER_SOFTWARE: str
1+
from typing import Final
2+
3+
version_info: Final[tuple[int, int, int]]
4+
__version__: Final[str]
5+
SERVER: Final[str]
6+
SERVER_SOFTWARE: Final[str]

stubs/gunicorn/gunicorn/arbiter.pyi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from queue import SimpleQueue
12
from types import FrameType
23
from typing import ClassVar
34

@@ -16,11 +17,11 @@ class Arbiter:
1617
START_CTX: ClassVar[dict[int | str, str | list[str]]]
1718
LISTENERS: ClassVar[list[BaseSocket]]
1819
WORKERS: ClassVar[dict[int, Worker]]
19-
PIPE: ClassVar[list[int]]
20-
SIG_QUEUE: ClassVar[list[int]]
20+
WAKEUP_REQUEST: ClassVar[int]
2121
SIGNALS: ClassVar[list[int]]
2222
SIG_NAMES: ClassVar[dict[int, str]]
2323
log: GLogger | None
24+
SIG_QUEUE: SimpleQueue[int]
2425
pidfile: Pidfile | None
2526
systemd: bool
2627
worker_age: int
@@ -42,7 +43,9 @@ class Arbiter:
4243
def init_signals(self) -> None: ...
4344
def signal(self, sig: int, frame: FrameType | None) -> None: ...
4445
def run(self) -> None: ...
45-
def handle_chld(self, sig: int, frame: FrameType | None) -> None: ...
46+
def signal_chld(self, sig: int, frame: FrameType | None) -> None: ...
47+
def handle_chld(self) -> None: ...
48+
handle_cld = handle_chld
4649
def handle_hup(self) -> None: ...
4750
def handle_term(self) -> None: ...
4851
def handle_int(self) -> None: ...
@@ -55,7 +58,7 @@ class Arbiter:
5558
def maybe_promote_master(self) -> None: ...
5659
def wakeup(self) -> None: ...
5760
def halt(self, reason: str | None = None, exit_status: int = 0) -> None: ...
58-
def sleep(self) -> None: ...
61+
def wait_for_signals(self, timeout: float | None = 1.0) -> list[int]: ...
5962
def stop(self, graceful: bool = True) -> None: ...
6063
def reexec(self) -> None: ...
6164
def reload(self) -> None: ...
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from gunicorn.asgi.lifespan import LifespanManager as LifespanManager
2+
from gunicorn.asgi.message import AsyncRequest as AsyncRequest
3+
from gunicorn.asgi.unreader import AsyncUnreader as AsyncUnreader
4+
5+
__all__ = ["AsyncUnreader", "AsyncRequest", "LifespanManager"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from _typeshed import Incomplete
2+
3+
from gunicorn.glogging import Logger as GLogger
4+
5+
from .._types import _ASGIAppType
6+
7+
class LifespanManager:
8+
app: _ASGIAppType
9+
logger: GLogger
10+
state: dict[Incomplete, Incomplete]
11+
12+
def __init__(self, app: _ASGIAppType, logger: GLogger, state: dict[Incomplete, Incomplete] | None = None) -> None: ...
13+
async def startup(self) -> None: ...
14+
async def shutdown(self) -> None: ...
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import re
2+
from typing import Final, Literal
3+
from typing_extensions import Self
4+
5+
from gunicorn.asgi.unreader import AsyncUnreader
6+
from gunicorn.config import Config
7+
8+
from .._types import _AddressType
9+
10+
MAX_REQUEST_LINE: Final = 8190
11+
MAX_HEADERS: Final = 32768
12+
DEFAULT_MAX_HEADERFIELD_SIZE: Final = 8190
13+
RFC9110_5_6_2_TOKEN_SPECIALS: Final = r"!#$%&'*+-.^_`|~"
14+
TOKEN_RE: Final[re.Pattern[str]]
15+
METHOD_BADCHAR_RE: Final[re.Pattern[str]]
16+
VERSION_RE: Final[re.Pattern[str]]
17+
RFC9110_5_5_INVALID_AND_DANGEROUS: Final[re.Pattern[str]]
18+
19+
class AsyncRequest:
20+
cfg: Config
21+
unreader: AsyncUnreader
22+
peer_addr: _AddressType
23+
remote_addr: _AddressType
24+
req_number: int
25+
version: tuple[int, int] | None
26+
method: str | None
27+
uri: str | None
28+
path: str | None
29+
query: str | None
30+
fragment: str | None
31+
headers: list[tuple[str, str]]
32+
trailers: list[tuple[str, str]]
33+
scheme: Literal["https", "http"]
34+
must_close: bool
35+
proxy_protocol_info: dict[str, str | int | None] | None # TODO: Use TypedDict
36+
limit_request_line: int
37+
limit_request_fields: int
38+
limit_request_field_size: int
39+
max_buffer_headers: int
40+
content_length: int | None
41+
chunked: bool
42+
43+
def __init__(self, cfg: Config, unreader: AsyncUnreader, peer_addr: _AddressType, req_number: int = 1) -> None: ...
44+
@classmethod
45+
async def parse(cls, cfg: Config, unreader: AsyncUnreader, peer_addr: _AddressType, req_number: int = 1) -> Self: ...
46+
def force_close(self) -> None: ...
47+
def should_close(self) -> bool: ...
48+
def get_header(self, name: str) -> str: ...
49+
async def read_body(self, size: int = 8192) -> bytes: ...
50+
async def drain_body(self) -> None: ...
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import asyncio
2+
from collections.abc import Iterable
3+
4+
from gunicorn.config import Config
5+
from gunicorn.glogging import Logger as GLogger
6+
from gunicorn.workers.gasgi import ASGIWorker
7+
8+
from .._types import _ASGIAppType
9+
10+
class ASGIResponseInfo:
11+
status: str | int
12+
sent: int
13+
headers: list[tuple[str, str]]
14+
15+
def __init__(self, status: str | int, headers: Iterable[tuple[str | bytes, str | bytes]], sent: int) -> None: ...
16+
17+
class ASGIProtocol(asyncio.Protocol):
18+
worker: ASGIWorker
19+
cfg: Config
20+
log: GLogger
21+
app: _ASGIAppType
22+
transport: asyncio.BaseTransport | None
23+
reader: asyncio.StreamReader | None
24+
writer: asyncio.BaseTransport | None
25+
req_count: int
26+
27+
def __init__(self, worker: ASGIWorker) -> None: ...
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import asyncio
2+
import io
3+
from _typeshed import ReadableBuffer
4+
5+
class AsyncUnreader:
6+
reader: asyncio.StreamReader
7+
buf: io.BytesIO
8+
max_chunk: int
9+
10+
def __init__(self, reader: asyncio.StreamReader, max_chunk: int = 8192) -> None: ...
11+
async def read(self, size: int | None = None) -> bytes: ...
12+
def unread(self, data: ReadableBuffer) -> None: ...
13+
def has_buffered_data(self) -> bool: ...
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import asyncio
2+
from typing import Final
3+
4+
from gunicorn.glogging import Logger as GLogger
5+
6+
from .._types import _ASGIAppType, _ScopeType
7+
8+
OPCODE_CONTINUATION: Final = 0x0
9+
OPCODE_TEXT: Final = 0x1
10+
OPCODE_BINARY: Final = 0x2
11+
OPCODE_CLOSE: Final = 0x8
12+
OPCODE_PING: Final = 0x9
13+
OPCODE_PONG: Final = 0xA
14+
CLOSE_NORMAL: Final = 1000
15+
CLOSE_GOING_AWAY: Final = 1001
16+
CLOSE_PROTOCOL_ERROR: Final = 1002
17+
CLOSE_UNSUPPORTED: Final = 1003
18+
CLOSE_NO_STATUS: Final = 1005
19+
CLOSE_ABNORMAL: Final = 1006
20+
CLOSE_INVALID_DATA: Final = 1007
21+
CLOSE_POLICY_VIOLATION: Final = 1008
22+
CLOSE_MESSAGE_TOO_BIG: Final = 1009
23+
CLOSE_MANDATORY_EXT: Final = 1010
24+
CLOSE_INTERNAL_ERROR: Final = 1011
25+
WS_GUID: Final = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
26+
27+
class WebSocketProtocol:
28+
transport: asyncio.Transport
29+
reader: asyncio.StreamReader
30+
scope: _ScopeType
31+
app: _ASGIAppType
32+
log: GLogger
33+
accepted: bool
34+
closed: bool
35+
close_code: int | None
36+
close_reason: str | None
37+
38+
def __init__(
39+
self, transport: asyncio.Transport, reader: asyncio.StreamReader, scope: _ScopeType, app: _ASGIAppType, log: GLogger
40+
) -> None: ...
41+
async def run(self) -> None: ...

stubs/gunicorn/gunicorn/config.pyi

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ _ClassValidatorType: TypeAlias = Callable[[object | str | None], type[Any] | Non
6363
_UserGroupValidatorType: TypeAlias = Callable[[str | int | None], int]
6464
_AddressValidatorType: TypeAlias = Callable[[str | None], _AddressType | None]
6565
_CallableValidatorType: TypeAlias = Callable[[str | _HookType], _HookType]
66+
_ProxyProtocolValidatorType: TypeAlias = Callable[[str | bool | None], str]
67+
_ASGILoopValidatorType: TypeAlias = Callable[[str | None], str]
68+
_ASGILifespanValidatorType: TypeAlias = Callable[[str | None], str]
6669

6770
_ValidatorType: TypeAlias = ( # noqa: Y047
6871
_BoolValidatorType
@@ -74,6 +77,9 @@ _ValidatorType: TypeAlias = ( # noqa: Y047
7477
| _UserGroupValidatorType
7578
| _AddressValidatorType
7679
| _CallableValidatorType
80+
| _ProxyProtocolValidatorType
81+
| _ASGILoopValidatorType
82+
| _ASGILifespanValidatorType
7783
)
7884

7985
KNOWN_SETTINGS: list[Setting]
@@ -138,7 +144,7 @@ class Setting(metaclass=SettingMeta):
138144
short: ClassVar[str | None]
139145
desc: ClassVar[str | None]
140146
nargs: ClassVar[int | str | None]
141-
const: ClassVar[bool | None]
147+
const: ClassVar[bool | str | None]
142148
order: ClassVar[int]
143149

144150
def __init__(self) -> None: ...
@@ -649,6 +655,7 @@ class SyslogTo(Setting):
649655
validator: ClassVar[_StringValidatorType]
650656
default: ClassVar[str]
651657
desc: ClassVar[str]
658+
default_doc: ClassVar[str]
652659

653660
class Syslog(Setting):
654661
name: ClassVar[str]
@@ -713,6 +720,15 @@ class StatsdPrefix(Setting):
713720
validator: ClassVar[_StringValidatorType]
714721
desc: ClassVar[str]
715722

723+
class BacklogMetric(Setting):
724+
name: ClassVar[str]
725+
section: ClassVar[str]
726+
cli: ClassVar[list[str]]
727+
validator: ClassVar[_BoolValidatorType]
728+
default: ClassVar[bool]
729+
action: ClassVar[str]
730+
desc: ClassVar[str]
731+
716732
class Procname(Setting):
717733
name: ClassVar[str]
718734
section: ClassVar[str]
@@ -906,13 +922,17 @@ class NewSSLContext(Setting):
906922

907923
def ssl_context(config: Config, default_ssl_context_factory: Callable[[], SSLContext]) -> SSLContext: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
908924

925+
def validate_proxy_protocol(val: str | bool | None) -> str: ...
926+
909927
class ProxyProtocol(Setting):
910928
name: ClassVar[str]
911929
section: ClassVar[str]
912930
cli: ClassVar[list[str]]
913-
validator: ClassVar[_BoolValidatorType]
914-
default: ClassVar[bool]
915-
action: ClassVar[str]
931+
meta: ClassVar[str]
932+
validator: ClassVar[_ProxyProtocolValidatorType]
933+
default: ClassVar[str]
934+
nargs: ClassVar[str]
935+
const: ClassVar[str]
916936
desc: ClassVar[str]
917937

918938
class ProxyAllowFrom(Setting):
@@ -923,6 +943,23 @@ class ProxyAllowFrom(Setting):
923943
default: ClassVar[str]
924944
desc: ClassVar[str]
925945

946+
class Protocol(Setting):
947+
name: ClassVar[str]
948+
section: ClassVar[str]
949+
cli: ClassVar[list[str]]
950+
meta: ClassVar[str]
951+
validator: ClassVar[_StringValidatorType]
952+
default: ClassVar[str]
953+
desc: ClassVar[str]
954+
955+
class UWSGIAllowFrom(Setting):
956+
name: ClassVar[str]
957+
section: ClassVar[str]
958+
cli: ClassVar[list[str]]
959+
validator: ClassVar[_ListStringValidatorType]
960+
default: ClassVar[str]
961+
desc: ClassVar[str]
962+
926963
class KeyFile(Setting):
927964
name: ClassVar[str]
928965
section: ClassVar[str]
@@ -1062,3 +1099,33 @@ class HeaderMap(Setting):
10621099
validator: ClassVar[_StringValidatorType]
10631100
default: ClassVar[str]
10641101
desc: ClassVar[str]
1102+
1103+
def validate_asgi_loop(val: str | None) -> str: ...
1104+
def validate_asgi_lifespan(val: str | None) -> str: ...
1105+
1106+
class ASGILoop(Setting):
1107+
name: ClassVar[str]
1108+
section: ClassVar[str]
1109+
cli: ClassVar[list[str]]
1110+
meta: ClassVar[str]
1111+
validator: ClassVar[_ASGILoopValidatorType]
1112+
default: ClassVar[str]
1113+
desc: ClassVar[str]
1114+
1115+
class ASGILifespan(Setting):
1116+
name: ClassVar[str]
1117+
section: ClassVar[str]
1118+
cli: ClassVar[list[str]]
1119+
meta: ClassVar[str]
1120+
validator: ClassVar[_ASGILifespanValidatorType]
1121+
default: ClassVar[str]
1122+
desc: ClassVar[str]
1123+
1124+
class RootPath(Setting):
1125+
name: ClassVar[str]
1126+
section: ClassVar[str]
1127+
cli: ClassVar[list[str]]
1128+
meta: ClassVar[str]
1129+
validator: ClassVar[_StringValidatorType]
1130+
default: ClassVar[str]
1131+
desc: ClassVar[str]

0 commit comments

Comments
 (0)