This is only the answer to part of your question, but I understand that when you create a new process, it usually inherits all the descriptors of the parent process. This includes such open files and sockets that you are listening to.
On UNIX, this is a side effect of using "fork", which duplicates the current process and all its descriptors before loading a new executable. On Windows, this is more explicit, but Python does it anyway to match behavior across platforms as much as possible.
The close_fds parameter, when True, closes all these inherited descriptors after spawning of the subprocess, so the new executable starts from scratch. But if your subprocesses are executed one at a time and end when they are finished, this should not be a problem.
source share