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), >> that >> 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 > you > probably should), it should be about the speed issue, with suggested > solutions attached, so people know the underlying issue you're > trying to > solve. > > 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. James _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python