[docs] [issue23254] Document how to close the TCPServer listening socket

Martin Panter report at bugs.python.org
Sat Jan 17 05:32:55 CET 2015


New submission from Martin Panter:

Running the example from the Asynchronous Mixins section of the “socketserver” documentation generates a ResourceWarning:

$ ./python -btWall ThreadedTCPServer.py
Server loop running in thread: Thread-1
Received: Thread-2: Hello World 1
Received: Thread-3: Hello World 2
Received: Thread-4: Hello World 3
sys:1: ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 43804)>

There is a server_close() method mentioned in the doc string of the BaseServer class, so I assume it is meant to be part of the API. But there is no mention of it in the reference documentation.

I think server.server_close() should be documented, and called after server.shutdown() in the example. A further enhancement might be to turn BaseServer into a context manager, but I would be happy with using the existing server_close() method.

----------
assignee: docs at python
components: Documentation
messages: 234161
nosy: docs at python, vadmium
priority: normal
severity: normal
status: open
title: Document how to close the TCPServer listening socket
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23254>
_______________________________________


More information about the docs mailing list