]> ToastFreeware Gitweb - gregoa/zavai.git/blobdiff - zavai/registry.py
Notes about remotising devices
[gregoa/zavai.git] / zavai / registry.py
index 67f4c78f6aa737971898455de44d75c07b481584..4fc210143ecb8568f3ad692328dbea2665db80d1 100644 (file)
@@ -169,9 +169,11 @@ class Service(Resource):
         self.callbacks = dict()
         for t in types:
             self.callbacks[t] = set()
+        self.started = False
 
     def shutdown(self):
-        self.stop()
+        if self.started:
+            self.stop()
 
     def start(self):
         "Activate the service"
@@ -197,6 +199,7 @@ class Service(Resource):
         self.callbacks[type].add(callback)
         if do_start:
             self.start()
+            self.started = True
 
     def disconnect(self, type, callback):
         "Disconnect a callback to this resource, activating it if needed"
@@ -204,3 +207,4 @@ class Service(Resource):
         self.callbacks[type].discard(callback)
         if not self.has_callbacks():
             self.stop()
+            self.started = False