[Twisted-Python] reload / restart best practices ?
twisted-python at 2xlp.com
Wed Jun 12 14:40:08 MDT 2013
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python