Activity lifecycle: Stop only the services on stop#111
Conversation
On stop: stop only the Kolibri services by directly calling ServicesPlugin.STOP. On resume: if the Kolibri bus is already started, start the services. If not, transition the bus to the START state which should start the services too.
4501f22 to
8f2be4a
Compare
| def start_services(self): | ||
| self._services.START() | ||
|
|
There was a problem hiding this comment.
It's possible for an activity's onStart() callback to run multiple times in between calls to onStop(), for example if the activity is paused but not stopped. Looking at ServicesPlugin source, it appears the iceqube engine is going to be created from scratch each time the START() function runs: https://github.com/learningequality/kolibri/blob/bbd63a9c1f0371dc5009f59375c43aec26092610/kolibri/utils/server.py#L255-L267.
So, I think we should add a way to keep track of whether the services plugin has been stopped or started so we aren't doing it needlessly. Perhaps add our own PausableServicesPlugin which keeps track of that state?
There was a problem hiding this comment.
Thanks for the feedback! I was able not only to skip the START when it wasn't stopped before, but also to partially start after stopped. To prevent calling schedule_ping() and schedule_vacuum() multiple times. See the fixup commit.
303e131 to
25e1f7e
Compare
On stop: stop only the Kolibri services by directly calling ServicesPlugin.STOP.
On resume: if the Kolibri bus is already started, start the services. If not, transition the bus to the START state which should start the services too.
https://phabricator.endlessm.com/T34626