[issue3392] subprocess fails in select when descriptors are large

Frank Chu report at bugs.python.org
Tue Mar 31 10:13:25 CEST 2009

Frank Chu <fpmchu at gmail.com> added the comment:


This is a patch that uses poll() in subprocess.communicate() if it is
available.  This is my first patch and may contain style errors.  I try
to conform to PEP 8 as close as I can.

Besides the discussion here, I would like to add this is desired because
select() has its own limit on the file descriptor size, in FD_SETSIZE. 
Unix has a different limit on the largest file descriptor, in 'ulimit
-n'.  When the select() limit is smaller than the ulimit limit, it is
not hard to get a file descriptor that is beyond FD_SETSIZE.  In that
case select() simply does not work.  Since there is no precise way to
force file descriptor to be small, the only workaround seems to be hack
like what hte first poster yorick suggests.

This is tested via 'python regrtest.py -w test_subprocess' under a
system that supports poll().  I don't have a system that does *not*
support poll, but I've done some manual edits to force that code path
and test it as well.  The test passes, which I think should be good
enough as it has several tests on communicate().

This patch is against 2.6.

keywords: +patch
nosy: +fpmc
Added file: http://bugs.python.org/file13511/subprocess_with_poll.diff

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list