CLI tools hidden in the Python standard library
2y 11mon ago by programming.dev/u/jim in python@programming.dev from til.simonwillison.netSeth Michael Larson pointed out that the Python gzip module can be used as a CLI tool like this:
It's worth noting that the http.server module is based on socketserver.BaseServer.serve_forever, which is a atrocious.
It uses a busy loop with a delay, so it both burns CPU and is unresponsive.
(The fact that Python has had broken signal handling since 3.5 also hurts - EINTR should never be ignored from blocking calls)
I was just about to uninstall nginx...
On a serious note: I'm not sure of the details of socketserver but I would think opening a socket would not be a cpu intensive process.
The comments in the code explain exactly what the problem is and how to fix it, and it would take less than 30 minutes to implement and test that (assuming you don't just grab someone else's version - there's a reason I know the time), but nobody has committed it in ... at least 13 years since the comment was written; I'm not digging any further through imported SVN history.
Thats neat. Thanks for sharing