#479 - Fixing reminder stop
- Setting daemon on timer to True to make timer thread cancelable - Refactoring shutdown to use super instead of static super - Removing cleanuppull/446/merge
parent
6b324c6df2
commit
672b208b86
|
@ -270,10 +270,9 @@ class MycroftSkill(object):
|
||||||
passed_time = time.time() - self.stop_time
|
passed_time = time.time() - self.stop_time
|
||||||
return passed_time < self.stop_threshold
|
return passed_time < self.stop_threshold
|
||||||
|
|
||||||
def cleanup(self):
|
|
||||||
""" Clean up running threads, etc. """
|
|
||||||
pass
|
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
"""
|
||||||
|
This method is intended to be called during the skill process termination.
|
||||||
|
The skill implementation must shutdown all processes and operations in execution.
|
||||||
|
"""
|
||||||
self.stop()
|
self.stop()
|
||||||
pass
|
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
import sys
|
||||||
from os.path import expanduser, exists
|
from os.path import expanduser, exists
|
||||||
|
|
||||||
from mycroft.configuration import ConfigurationManager
|
from mycroft.configuration import ConfigurationManager
|
||||||
|
@ -84,4 +86,6 @@ if __name__ == "__main__":
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
for skill in skills:
|
for skill in skills:
|
||||||
skill.shutdown()
|
skill.shutdown()
|
||||||
|
finally:
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ class ScheduledSkill(MycroftSkill):
|
||||||
now = self.get_utc_time()
|
now = self.get_utc_time()
|
||||||
delay = max(float(t) - now, 1)
|
delay = max(float(t) - now, 1)
|
||||||
self.timer = Timer(delay, self.notify, [t])
|
self.timer = Timer(delay, self.notify, [t])
|
||||||
|
self.timer.daemon = True
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
@ -113,15 +114,9 @@ class ScheduledSkill(MycroftSkill):
|
||||||
def notify(self, timestamp):
|
def notify(self, timestamp):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def cleanup(self):
|
|
||||||
""" Cancel timer making the skill ready for shutdown """
|
|
||||||
if self.timer:
|
|
||||||
self.timer.cancel()
|
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
MycroftSkill.shutdown(self)
|
super(ScheduledSkill, self).shutdown()
|
||||||
if self.timer:
|
self.cancel()
|
||||||
self.timer.cancel()
|
|
||||||
|
|
||||||
|
|
||||||
class ScheduledCRUDSkill(ScheduledSkill):
|
class ScheduledCRUDSkill(ScheduledSkill):
|
||||||
|
|
Loading…
Reference in New Issue