Didn’t find a server.closeAllConnections() call in the
bundled Python3 http server. But shutdown of a server
hangs especially if requests are served with HTTP/1.1
and if the HTTP client then uses keep alive connections:
protocol_version = 'HTTP/1.1'
A workaround is presented here on stack overflow. Didn’t try yet:
How do I forcibly disconnect all currently connected clients
https://stackoverflow.com/a/71072988/17524790
I only noticed that most Java http servers include a connection
teardown in their stop routine and that JavaScript node.js
recently introduced server.closeAllConnections(). So in node.js I use:
obj.close(err => {
resolve();
});
obj.closeAllConnections();
It might come handy to have the same available in Python.