[Twisted-web] spawning a xvfb and firefox with a timeout
schenette at gmail.com
Mon Aug 22 05:16:21 EDT 2011
env=os.environ to spanProcess fixed the issue, thank you.
There is still one problem I brought up that I'm attempting to figure
out with twisted that is related to the initial question...
current status is that now with the addition of setting the env params
xvfb starts up correctly and starts up firefox.
the ProcessProtocol object that I created, has a calllater function
that kills the process after 20seconds.
the issue is that xvfb has one process id and any process it's asked
to create will cause another process to be spawned, thus another
process id, where the parent process is that of xvfb.
when I issue the kill command, xvfb does indeed die, but firefox-bin
stays around and it's parent is set to 1.
here is the ProcessProtocol code, should I be killing the parent
process differently so that the children die as well?
33 class TimedProcessProtocol(protocol.ProcessProtocol):
35 def __init__(self, timeout):
36 self.timeout = timeout
38 def connectionMade(self):
39 logging.debug("connection made timeout = %d", self.timeout)
41 def killIfAlive():
42 logging.debug("timeout reached - killing process")
44 yield self.transport.signalProcess('TERM')
45 except error.ProcessExitedAlready:
46 logging.debug("process already exited")
49 d = reactor.callLater(self.timeout, killIfAlive)
51 def outReceived(self, data):
52 logging.debug("output: %s", data)
ps both TERM and KILL act the same way
On Sat, Aug 20, 2011 at 2:01 PM, <exarkun at twistedmatrix.com> wrote:
> On 19 Aug, 04:42 am, schenette at gmail.com wrote:
>>I'm attempting to spawn xvfb with firefox using twisted's spawnProcess.
>>I'm having two issues:
>>1) when I call a normal process (not xvfb) it seems to
>>work, but when I call xvfb the process goes defunct
>>2) perhaps because it goes defunct but the timeout I set in place in
>>the processprotocol does
>>here is the code for spawning a process
>>108 command = ["/usr/bin/xvfb-run", "--auto-servernum",
>>"/usr/bin/firefox", "-P", profile_id]
>>109 subprocess = reactor.spawnProcess(TimedProcessProtocol(20),
>>110 command, command)
> Does it make any difference if you pass on the parent's environment to
> the xvfb-run process? Try something like spawnProcess(...,
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
More information about the Twisted-web