test_subprocess is currently very slow and the main culprit is test_no_leaking (here, it takes 80s out of the 100s needed for the whole run). This tests spawns as many subprocesses as would be needed to reach the max file descriptor limit. Spawning a subprocess is a heavy operation and consequently the test is very long. This patch adopts another approach: it opens many file descriptors (using os.open()) until the max fd limit is reached, closes some of them (10 is enough) and then launches a bunch of subprocesses in a loop to check that they succeed. Consequently, the test is very fast (even on a Windows VM in debug mode).
Overall I like the approach. A few questions / clarifications: is errno.EMFILE portable? will that errno test work on both posix and windows? should the is_resource_enabled('subprocess') stuff be preserved (why was it there to begin with? because the old test took so long?)
> A few questions / clarifications: > > is errno.EMFILE portable? will that errno test work on both posix and > windows? It does (tested under Linux and a Win64 VM). > should the is_resource_enabled('subprocess') stuff be preserved (why was it > there to begin with? because the old test took so long?) I guess the latter: the test was so long, especially on slow machines, that it was only enabled selectively.