[Twisted-Python] "glue" problem

Maarten ter Huurne maarten at treewalker.org
Sat Apr 19 11:59:28 EDT 2008

On Saturday 19 April 2008, Dr Pythoniac wrote:

> How do I run once-per-application stuff ?
> Assume, I want to put sth into the static.Registry or  I want to read in
> some application data from a file, so that every resource can use it.
> My main problem can be split in two:
> - where do it do it (using twistd) ?

For our webapp, we load lots of data, so I made a "startup in progress" page 
which both does the loading and serves a page that shows how much is loaded 
so far. The loading itself is done by loading small chunks of data and then 
returning control back to the reactor, so it can actually serve the 
progress page. When loading is done, the progress page resource is replaced 
by the root page of the webapp.

If you only want to load a small amount of data, maybe subclass Application? 
I haven't tried this though.

Our webapp loads from a Python file (using "twistd -y"), so that first 
Python file could also load data. If I recall correctly, that initial file 
is run as the same user that started twistd (root, in our case), while the 
started application runs as the user selected from the twistd --uid 
and --gid options. So it is safer to do as little as possible at this stage 
of startup.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20080419/14895fcc/attachment.pgp 

More information about the Twisted-Python mailing list