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"
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"
if not self.has_callbacks(): return
- self.callbacks.discard(callback)
+ self.callbacks[type].discard(callback)
if not self.has_callbacks():
self.stop()
+ self.started = False