This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SimpleXMLRPCServer Socket not closed after shutdown call
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: othererik, santoso.wijaya, terry.reedy
Priority: normal Keywords:

Created on 2010-04-23 12:38 by othererik, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg104009 - (view) Author: Erik Schweller (othererik) Date: 2010-04-23 12:38
Calling shutdown on a SimpleXMLRPCServer will stop the server but does not close the socket, meaning new connections to the same address will fail. 

Example:

  srv = SimpleXMLRPCServer((ip, port),
                                      logRequests=False, allow_none=True)
  srv.serve_forever(poll_interval=2)


srv.shutdown() is made available to the registered class instance.


The current workaround is to delete the socket (or call close() on the socket) after the server is shutdown, (i.e., "del srv.socket") but it seems this should be handled when the server is shutdown.
msg113040 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-05 20:25
The behavior is as documented, so this is a feature request.
The 3.1.2 doc in 20.19.2. Server Objects says
"BaseServer.shutdown() 
Tells the serve_forever() loop to stop and waits until it does."

I presume this allows subsequent .handle_request() and ..serve_forever() calls, as well as others, so I think the request is a bad idea.

For automatic closing, use 'with' statements and a context manager and checkout contextlib. This is their main purpose.

I am not sure what
"The server classes support the following class variables:
BaseServer.allow_reuse_address 
Whether the server will allow the reuse of an address. This defaults to False, and can be set in subclasses to change the policy." 
or whether it would help you.
History
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52752
2010-08-05 20:25:47terry.reedysetstatus: open -> closed

nosy: + terry.reedy
messages: + msg113040

type: behavior -> enhancement
resolution: rejected
2010-04-27 16:44:46santoso.wijayasetnosy: + santoso.wijaya
2010-04-23 12:38:03othererikcreate