Skip to content

Commit 872e832

Browse files
author
Jakub Stasiak
committed
Add BaseRequestHandler instance attributes
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. I also added a union that expresses the fact that client_address can be a string in case of using Unix domain sockets.
1 parent c1b1297 commit 872e832

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stdlib/3/socketserver.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Stubs for socketserver
22

3-
from typing import BinaryIO, Optional, Tuple
3+
from typing import BinaryIO, Optional, Tuple, Union
44
from socket import SocketType
55
import sys
66
import types
@@ -69,6 +69,9 @@ class ThreadingTCPServer(ThreadingMixIn, TCPServer): ...
6969
class ThreadingUDPServer(ThreadingMixIn, UDPServer): ...
7070

7171
class BaseRequestHandler:
72+
request = ... # type: Union[SocketType, Tuple[bytes, SocketType]]
73+
client_address = ... # type: Union[Tuple[str, int], str]
74+
server = ... # type: BaseServer
7275
def setup(self) -> None: ...
7376
def handle(self) -> None: ...
7477
def finish(self) -> None: ...

0 commit comments

Comments
 (0)