[Twisted-Python] reactor.spawnProcess() and file descriptors
James Y Knight
foom at fuhm.net
Mon Jun 28 10:30:37 EDT 2010
On Jun 28, 2010, at 9:03 AM, Itamar Turner-Trauring wrote:
> On Mon, 2010-06-28 at 13:21 +0100, Carlos Valiente wrote:
>> I wanted to skip the calls to close()
>> -- 1024 of them, in my case -- because, according to strace(1),
>> takes about 100 ms (and I'd like to save those milliseconds).
> Ah, I see. So the issue is performance. If you do file a ticket (and
> probably should), it should be about the speed issue, with suggested
> solutions attached, so people know the underlying issue you're
> trying to
> It's quite likely that closing could be sufficiently sped up by
> having a
> tiny C extension do it -- less Python overhead, and you don't have to
> raise and catch 1000 exceptions (which is fairly expensive).
Or, if just listdir("/proc/%d/fd/" % getpid()). If that doesn't fail
(aka /proc/pid/fd actually exists and is mounted on this OS) then only
close the listed fds. That'll be much much faster.
More information about the Twisted-Python