SV: [Twisted-Python] Reloading server configuration.

Mattias Brändström mattias.brandstrom at
Mon Aug 18 06:12:41 EDT 2008

> -----Ursprungligt meddelande-----
> Från: twisted-python-bounces at [mailto:twisted-python-
> bounces at] För lasizoillo
> Skickat: den 15 augusti 2008 18:22
> Till: Twisted general discussion
> Ämne: Re: [Twisted-Python] (no subject)
> Hello
> 2008/8/12 Mattias Brändström <mattias.brandstrom at>:
> > Hello!
> >
> > Is there any way I can make twisted stop accepting connections for a
> short period of time and then start accepting connections? Something like
> reactor.pause()?
> >
> > More precisely, what I want to do is to reread my server configuration
> on SIGHUP (or some other external event). If possible I would like to do
> this without locking a mutex when accessing (reading or modifying) the
> configuration info. I figure that reconfiguring the server will be a rare
> event. So if there is some way that I can:
> >
> > 1. Block incoming requests. Preferable keeping them in the connection
> queue.
> > 2. Wait for all running requests to complete.
> > 3. Reread the server configuration.
> > 4. Unblock incoming requests.
> >
> > What do you think? Is there some simple twisted-way to do this?
> >
> It's really necesary do that?
> 1 Your app have a reference to a object whith the loaded config
> 2 A defered take a reference to these object
> 3 A reread event change the app config reference to new loaded config
> object. Old defered no change his reference and end whith old config.
> 4 New defereds take new config and reference that.
> 5 When old config object have not references is garbaged collected.
> No blocking operation is nedded if you can load 2 configuration
> objects in memory (the old one for connections in progress and the new
> one).

OK. This seems like a good approach. However, I am using twisted.web.server.Site as my factory and the resources tied to my Site instance are the ones that need to access the server configuration. How would I go about giving each request its own configuration reference in this case? I'm quite new to twisted and it's not entirely clear to me how to achieve this. :-)

:.:: mattias

More information about the Twisted-Python mailing list