[Twisted-Python] reload / restart best practices ?

Terry Jones terry at jon.es
Wed Jun 12 15:05:33 MDT 2013


Hi Jonathan

You might also find something like this useful:
http://twistedmatrix.com/pipermail/twisted-python/2009-December/021107.html

Optionally, it would be easy to add a timeout value to the class that could
cancel outstanding deferreds after a certain amount of time and then fire
all the waiters.

Terry



On Wed, Jun 12, 2013 at 9:40 PM, Jonathan Vanasco
<twisted-python at 2xlp.com>wrote:

>
> On Jun 12, 2013, at 4:31 PM, Glyph wrote:
>
> I'm not sure what "autoload" is.  I am assuming it's some kind of
> auto-re-loading technology though.
>
>
> The earlier discussions talked about Django's autoload, which reloads the
> entire process on a config file change.
>
> You *do* want to re-start your process.  What you're diagnosing is some
> weird, unknown thread/process interaction and unless you get a clean slate,
> you don't know what is happening.
>
> You may not want to do so *immediately*, though, since, as you say:
>
>
> Correct on both accounts.  I don't want to kill the current process while
> it's talking to an API.  I just want it to not talk to any additional APIs,
> then kill the process a bit later.
>
> I'd like them to finish , and shutdown/restart N seconds later ( assuming
> that I wouldn't be able to fully shutdown because of an issue with a locked
> thread ).
>
>
> The issue is with letting them finish.  In order to accomplish this, you
> should write IService implementations that have stopService methods that,
> when called, will wait for any operations in flight associated with that
> service.
>
> Once everything is quiesced, you can re-exec ([sys.executable] + sys.argv)
> and that ought to result in the same process starting up again.  If you've
> done the appropriate thing and made all your stopService methods wait for
> their operations to complete, then waiting for them all to complete is just
> putting them all into a MultiService, calling stopService() on that
> MultiService, and adding a callback/errback to the Deferred it returns
> which calls os.exec.
>
>
> ok great !  I'll look into StopService and IService tomorrow !
>
> thanks a ton.  that's pretty much what i want/need.
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20130612/01e634d7/attachment.html>


More information about the Twisted-Python mailing list