Author martin.panter
Recipients martin.panter, palaviv, terry.reedy
Date 2016-02-29.22:54:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Server_close() was only documentated last year; see Issue 23254. For the examples that run until you interrupt them, the servers currently emit a resource warning (in addition to the KeyboardInterrupt traceback and the Python 2 bytes warnings):

$ python -bWall wrote: BytesWarning: str() on a bytes instance
b'hello world with TCP' wrote: BytesWarning: str() on a bytes instance
b'python is nice'
^CTraceback (most recent call last):
  File "", line 28, in <module>
  File "/usr/lib/python3.5/", line 237, in serve_forever
    ready =
  File "/usr/lib/python3.5/", line 367, in select
    fd_event_list = self._poll.poll(timeout)
sys:1: ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('', 9999)>
[Exit 1]

If you ignore the warning, there isn’t much effective difference, because the socket gets closed when the process exits, or if you are lucky, when Python garbage collects the global “server” object. But IMO it is bad practice not to clean up resources properly, especially in an API example.
Date User Action Args
2016-02-29 22:54:51martin.pantersetrecipients: + martin.panter, terry.reedy, palaviv
2016-02-29 22:54:51martin.pantersetmessageid: <>
2016-02-29 22:54:51martin.panterlinkissue26404 messages
2016-02-29 22:54:50martin.pantercreate