Exemple #1
0
 def stopService(self):
     """
     Stop all of my Services.
     I return a Deferred that results in a dict that looks like
     {serviceObject: (successOrFailure, result)}, where
     successOrFailure is a boolean and result is the result of the
     Deferred returned by serviceObject.stopService.
     """
     ApplicationService.stopService(self)
     v = self.services.values()
     l = [svc.stopService() or defer.succeed(None) for svc in v]
     return defer.DeferredList(l).addBoth(self._cbAttachServiceNames, v)
Exemple #2
0
 def startService(self):
     """
     Start all of my Services.
     I return a Deferred that will callback (with no useful result)
     when all services are started.  In the event of a failure, all 
     of the successful services will be stopped (without chained behavior)
     and I will errback with the first unsuccessful service's failure.
     """
     def startServiceDeferred(res, service):
         return service.startService() or defer.succeed(None)
     d = defer.succeed(None)
     for svc in self.services.values():
         d.addCallbacks(startServiceDeferred, callbackArgs=(svc,),
             errback=self._rollbackStartedServices, errbackArgs=(svc,))
     return d.addCallback(self._finishStartService)
Exemple #3
0
    def stopService(self):
        """
        Stop all of my Services.

        I return a Deferred that results in a dict that looks like
        {serviceObject: (successOrFailure, result)}, where
        successOrFailure is a boolean and result is the result of the
        Deferred returned by serviceObject.stopService.
        """
        ApplicationService.stopService(self)
        v = self.services.values()
        # The default stopService returns None, but you can't make that part
        # of a DeferredList.
        l = [svc.stopService() or defer.succeed(None) for svc in v]
        return defer.DeferredList(l).addBoth(self._cbAttachServiceNames, v)
Exemple #4
0
 def stopService(self):
     """
     Stop all of my Services.
     I return a Deferred that will callback (with no useful result)
     when all services are stopped.  In the event of a failure, the 
     running services will be stopped (without chained behavior) and 
     I will errback with the first unsuccessful service's failure.
     """
     def stopServiceDeferred(res, service):
         return service.stopService() or defer.succeed(None)
     v = self.services.values()
     v.reverse()
     d = defer.succeed(None)
     for svc in v:
         d.addCallbacks(stopServiceDeferred, callbackArgs=(svc,),
             errback=self._emergencyStopService, errbackArgs=(svc,))
     return d.addCallback(self._finishStopService)
Exemple #5
0
    def startService(self):
        """
        Start all of my Services.

        I return a Deferred that will callback (with no useful result)
        when all services are started.  In the event of a failure, all 
        of the successful services will be stopped (without chained behavior)
        and I will errback with the first unsuccessful service's failure.
        """
        def startServiceDeferred(res, service):
            return service.startService() or defer.succeed(None)

        d = defer.succeed(None)
        for svc in self.services.values():
            d.addCallbacks(startServiceDeferred,
                           callbackArgs=(svc, ),
                           errback=self._rollbackStartedServices,
                           errbackArgs=(svc, ))
        return d.addCallback(self._finishStartService)
Exemple #6
0
    def stopService(self):
        """
        Stop all of my Services.

        I return a Deferred that will callback (with no useful result)
        when all services are stopped.  In the event of a failure, the 
        running services will be stopped (without chained behavior) and 
        I will errback with the first unsuccessful service's failure.
        """
        def stopServiceDeferred(res, service):
            return service.stopService() or defer.succeed(None)

        v = self.services.values()
        v.reverse()
        d = defer.succeed(None)
        for svc in v:
            d.addCallbacks(stopServiceDeferred,
                           callbackArgs=(svc, ),
                           errback=self._emergencyStopService,
                           errbackArgs=(svc, ))
        return d.addCallback(self._finishStopService)
Exemple #7
0
 def stopServiceDeferred(res, service):
     return service.stopService() or defer.succeed(None)
Exemple #8
0
 def _finishStopService(self, res):
     return ApplicationService.stopService(self) or defer.succeed(None)
Exemple #9
0
 def stopServiceDeferred(res, service):
     return service.stopService() or defer.succeed(None)
Exemple #10
0
 def _finishStopService(self, res):
     return ApplicationService.stopService(self) or defer.succeed(None)