mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-35934: Add socket.create_server() utility function (GH-11784)
This commit is contained in:
parent
58721a9030
commit
eb7e29f2a9
17 changed files with 289 additions and 88 deletions
|
@ -60,21 +60,13 @@ class FunctionalTestCaseMixin:
|
|||
else:
|
||||
addr = ('127.0.0.1', 0)
|
||||
|
||||
sock = socket.socket(family, socket.SOCK_STREAM)
|
||||
|
||||
sock = socket.create_server(addr, family=family, backlog=backlog)
|
||||
if timeout is None:
|
||||
raise RuntimeError('timeout is required')
|
||||
if timeout <= 0:
|
||||
raise RuntimeError('only blocking sockets are supported')
|
||||
sock.settimeout(timeout)
|
||||
|
||||
try:
|
||||
sock.bind(addr)
|
||||
sock.listen(backlog)
|
||||
except OSError as ex:
|
||||
sock.close()
|
||||
raise ex
|
||||
|
||||
return TestThreadedServer(
|
||||
self, sock, server_prog, timeout, max_clients)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue