mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Add BaseRequestHandler instance attributes (#384)
From the BaseRequestHandler documentation:
handle()
This function must do all the work required to service a request.
The default implementation does nothing. Several instance attributes
are available to it; the request is available as self.request; the
client address as self.client_address; and the server instance as
self.server, in case it needs access to per-server information.
The type of self.request is different for datagram or stream
services. For stream services, self.request is a socket object;
for datagram services, self.request is a pair of string and
socket.
This commit is contained in:
committed by
Guido van Rossum
parent
cd413c502c
commit
b91b932d4f
@@ -1,6 +1,6 @@
|
||||
# Stubs for socketserver
|
||||
|
||||
from typing import BinaryIO, Optional, Tuple
|
||||
from typing import Any, BinaryIO, Optional, Tuple
|
||||
from socket import SocketType
|
||||
import sys
|
||||
import types
|
||||
@@ -68,7 +68,18 @@ class ForkingUDPServer(ForkingMixIn, UDPServer): ...
|
||||
class ThreadingTCPServer(ThreadingMixIn, TCPServer): ...
|
||||
class ThreadingUDPServer(ThreadingMixIn, UDPServer): ...
|
||||
|
||||
|
||||
class BaseRequestHandler:
|
||||
# Those are technically of types, respectively:
|
||||
# * Union[SocketType, Tuple[bytes, SocketType]]
|
||||
# * Union[Tuple[str, int], str]
|
||||
# But there are some concerns that having unions here would cause
|
||||
# too much inconvenience to people using it (see
|
||||
# https://github.com/python/typeshed/pull/384#issuecomment-234649696)
|
||||
request = ... # type: Any
|
||||
client_address = ... # type: Any
|
||||
|
||||
server = ... # type: BaseServer
|
||||
def setup(self) -> None: ...
|
||||
def handle(self) -> None: ...
|
||||
def finish(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user