[Twisted-Python] High Level Implementation Question

Moshe Zadka m at zadka.site.co.il
Thu Oct 23 02:50:21 EDT 2003


On Wed, Oct 22, 2003 at 12:56:37PM -0700, Nathan Seven wrote:
 
> > And then- why am I "supposed" to use twisted.app?
> > I don't need app-level persistance, and this is on
> > dedicated machines where I can just background the
> > process in the startup scripts- so daemonization is
> > not needed? Am I missing something in that?

On Thu, 23 Oct 2003, Andrew Bennetts <andrew-twisted at puzzling.org> wrote:
 
> I'll let someone who actually knows something about the new app stuff answer
> this :)

Well, I guess that means me :) 

First things first: you don't *need* app. Writing a Python script which
ends with .run() is a perfectly fine way to run Twisted. As long as you
can afford to modify it whenever you want profiling information. And
as long as you are willing to modify it whenever you want a log file.
And as long as you are sure backgrounding is a good enough approximation
for you. And as long as you don't need pid files. But at some point,
you are likely to want those things. twisted.application is a way to
*separate configuration from deployment*. It represents a layer of indirection
between your code (so-called business logic) and between the running, with
all the traditional costs and benefits of such indirection.

I strongly suggest reading the tutorial [in CVS] -- it starts out using
reactor.run(), and eventually progresses to use application. I think the
most important thing, for me, here is the core realization: your code
should (probably) know very little about whether it is being used with
an application or just a reactor.run(). Even when using Services, you
can easily have your script do something like:

s.startService()
reactor.run()
s.stopService()




More information about the Twisted-Python mailing list