
On 11:14 am, exarkun@divmod.com wrote:
On Mon, 02 Jul 2007 11:04:56 +0200, Markus Schiltknecht <markus@bluegap.ch> wrote:
[snip] Anyway, with very simple timing measures within the twisted server itself, I've figured out what was causing the delays: reactor.spawnProcess() takes more than a second. I knew that fork() was expensive, but that expensive?
This isn't normal.
Markus, can you instrument spawnProcess and figure out which *part* of it is taking so long? Like exarkun says: this is not normal. (I wonder if we are unwittingly calling some blocking API in there? I don't think so, but...)
What I'm doing now feels very dirty: I'm calling reactor.spawnProcess() from a thread. (Yes, I'm taking care that only one thread can spawn a process at any time.) At least on my Linux Dev- Box, that seems to work - and resolves my issue. But... calling fork() from a thread???
Er. That's not supported. The only Twisted API you can call from a thread is reactor.callFromThread.
In other words, this may appear to work, but if you suddenly burst into flame unexpectedly, don't blame *us*. And you probably will, eventually, if you keep doing that.