
Peter, I assume you're using a MultiService to hold all of these services. You could delay adding the dependent services to the MultiService until the setup service has finished doing what it does. For instance, something like this (untested): class SetupService(Service): def __init__(self): self.done = defer.Deferred() def startService(self): # do things self.done.callback(None) def makeService(...): ms = MultiService() setup = SetupService() setup.done.addCallback(addTheOtherServicesTo, ms) Or maybe there's a better built-in way to do this that I don't know about. Matt On Wed, Nov 27, 2013 at 7:58 AM, Peter Westlake <peter.westlake@pobox.com> wrote:
I have a Twisted application with several Services. One of them has a startService method that does some setup asynchronously. This can go wrong if the next service to start makes a call to the first one, and it isn't ready yet. One way round it would be to make all methods on the slow service returned a Deferred (e.g. "self.slow_init.addCallback(self.actual_method)", but it seems a shame to have to do that every time when the situation only occurs when the daemon starts up. So would it be possible for t.a.s.Service.startService to be allowed to return a Deferred? Then the next service would only be started up when the Deferred fired.
Peter.
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python