[Twisted-Python] tracking spawned jobs in a twisted application (code review request)

Schneider, Michael michael.l.schneider at ugsplm.com
Mon Mar 1 11:28:26 EST 2004

Hello All,

I have been pushing some code around.

My problem is that I need to execute OS command line
jobs with twisted.

I started by morphing the twisted tutorial app into a
job runner.

My first path (It was wrong!!) was to morph the database connection
pool to a compute pool using popen2.

This group, suggested that I use reactor.spawn instead of popen2 .

Attached is the resulting code.  

Basic Approach for Command protocol.processProtocol:

1) crate a JobPool Object to manage list of running jobs
2) Create Job Runner Object to wrap individual process info,
   and capture process output.
   (start time, stop time ...)
3) Create CmdProcProtcol  to manage interaction with the reactor

I morphed the twisted application: (Coded in comment section below)
	1) Create JobPoolService
	2) Create JobRunnerProtocol
	3) Create XmlRpc Job Runner Interface that dispatches to job runner service.

My questions are:
	- Is the the twisted way?
      - What are some alternative approaches?
	- Is there a better way?

Thank you very much,
Michael Schneider
Senior Software Engineering Consultant
UGS PLM Solutions - an EDS Company
"The Greatest Performance Improvement Is the transitioning from a non-working state to the working state"

> -----Original Message-----
> From: twisted-python-admin at twistedmatrix.com
> [mailto:twisted-python-admin at twistedmatrix.com]On Behalf Of 
> Schollnick,
> Benjamin
> Sent: Monday, March 01, 2004 10:26 AM
> To: 'twisted-python at twistedmatrix.com'
> Subject: RE: [Twisted-Python] SSH connection, redux!
> Folks,
> 	Thanks for the support, so far...  I downloaded the
> precompiled version of the PyCrypto and everything is working fine...
> 	Except for the fact, that I am attempting to figure out
> how to make this work the way, that I *believe* it needs to work...
> 	By the way, I was unable to get the "Writing a client with 
> Twisted.Conch" FAQ to work....  I did find the sshSimpleClient.py
> example, and that is working okay...
> 	But I am having a problem, trying to figure out how to 
> adapt the 
> reactor model with my program...
> 	The application has, for example, 6 "ssh queries" that 
> it needs to
> send, for example a "/usr/sbin/prtconf -v", and then 
> "capture" the output,
> and return the output
> for processing...
> 	Then it proceeds to the next query....etc...
> 	Is there a method that I can setup the communication, 
> and say....
> reactor.send ("asdfasdf")
> data = reactor.recv ()
> 	More along the telnetlib design?  This way, I could branch the
> telnet code
> I use?
> 	Once, I start the reactor, I do not see where I can get 
> data in and
> out,
> without using some form of a global variable...  (Or 
> embedding the reactor
> inside
> another object)
> 				- Benjamin
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list