Module: properly end timer threads by tracking when module's shutdown() was called
This commit is contained in:
parent
0c5fe348dc
commit
80f2ff469c
@ -46,6 +46,8 @@ class Module(object):
|
|||||||
self.config = config
|
self.config = config
|
||||||
self.server = server
|
self.server = server
|
||||||
|
|
||||||
|
self.is_shutdown = False
|
||||||
|
|
||||||
# open database connection
|
# open database connection
|
||||||
dbfile = self.config.get('dr.botzo', 'database')
|
dbfile = self.config.get('dr.botzo', 'database')
|
||||||
self.conn = sqlite3.connect(dbfile)
|
self.conn = sqlite3.connect(dbfile)
|
||||||
@ -163,6 +165,8 @@ class Module(object):
|
|||||||
will call save() before this, so implement appropriately.
|
will call save() before this, so implement appropriately.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self.is_shutdown = True
|
||||||
|
|
||||||
def remove_metaoptions(self, list):
|
def remove_metaoptions(self, list):
|
||||||
"""Remove metaoptions from provided list, which was probably from a config file."""
|
"""Remove metaoptions from provided list, which was probably from a config file."""
|
||||||
|
|
||||||
@ -235,10 +239,10 @@ class Module(object):
|
|||||||
|
|
||||||
# don't actually do stuff if, since the last timer registration,
|
# don't actually do stuff if, since the last timer registration,
|
||||||
# the interval was set to 0
|
# the interval was set to 0
|
||||||
if self.timer_interval() > 0:
|
if self.timer_interval() > 0 and self.is_shutdown == False:
|
||||||
self.timer_do()
|
self.timer_do()
|
||||||
|
|
||||||
if self.timer_interval() > 0:
|
if self.timer_interval() > 0 and self.is_shutdown == False:
|
||||||
Timer(self.timer_interval(), self.timer_bootstrap, ()).start()
|
Timer(self.timer_interval(), self.timer_bootstrap, ()).start()
|
||||||
|
|
||||||
def timer_do(self):
|
def timer_do(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user