[Twisted-Python] stopping MultiService child services
Hi all, I'm still a bit of a novice but I'm trying to implement MultiService. The trick is that I want my program to be able to change it's config while it is running. Once the app realizes it has a new configuration it needs to stop all services, load the new config and start services accordingly. However, I'm stuck right now with how to stop all services. I'm thinking I need to loop over the children of MultiService and call stopService on them, but I'm not sure how to do that. Or should I just call stopServivce on the MultiService object? Thanks, Don
On Sat, 8 Dec 2007 08:52:36 -0800, Don Smith
Hi all,
I'm still a bit of a novice but I'm trying to implement MultiService. The trick is that I want my program to be able to change it's config while it is running. Once the app realizes it has a new configuration it needs to stop all services, load the new config and start services accordingly. However, I'm stuck right now with how to stop all services. I'm thinking I need to loop over the children of MultiService and call stopService on them, but I'm not sure how to do that. Or should I just call stopServivce on the MultiService object?
MultiService.stopService will call stopService on all of its child services, so if the goal is to do that, then a for loop is more work for the same result. When you call stopService, keep in mind that it can return a Deferred which you'll probably want to wait for before trying to start anything again. Likewise for startup, you can just call MultiService.startService to start all of its children. It might also be useful to know that removing a service from a running MultiService will stop the service and adding a service to a running MultiService will start it. Jean-Paul
Thank you, this was very helpful!
-Don
On Dec 8, 2007 9:09 AM, Jean-Paul Calderone
On Sat, 8 Dec 2007 08:52:36 -0800, Don Smith
wrote: Hi all,
I'm still a bit of a novice but I'm trying to implement MultiService. The trick is that I want my program to be able to change it's config while it is running. Once the app realizes it has a new configuration it needs to stop all services, load the new config and start services accordingly. However, I'm stuck right now with how to stop all services. I'm thinking I need to loop over the children of MultiService and call stopService on them, but I'm not sure how to do that. Or should I just call stopServivce on the MultiService object?
MultiService.stopService will call stopService on all of its child services, so if the goal is to do that, then a for loop is more work for the same result.
When you call stopService, keep in mind that it can return a Deferred which you'll probably want to wait for before trying to start anything again.
Likewise for startup, you can just call MultiService.startService to start all of its children.
It might also be useful to know that removing a service from a running MultiService will stop the service and adding a service to a running MultiService will start it.
Jean-Paul
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (2)
-
Don Smith
-
Jean-Paul Calderone