mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-07 19:49:23 +01:00
Make sure the MarkovWorkQueue dies.
This commit is contained in:
parent
451e083aec
commit
0bdbae6e47
@ -90,7 +90,8 @@ class DbmMarkovDB(object):
|
|||||||
def _getDb(self, channel):
|
def _getDb(self, channel):
|
||||||
if channel not in self.dbs:
|
if channel not in self.dbs:
|
||||||
# Stupid anydbm seems to append .db to the end of this.
|
# Stupid anydbm seems to append .db to the end of this.
|
||||||
self.dbs[channel] = anydbm.open('%s-DbmMarkovDB' % channel, 'c')
|
filename = plugins.makeChannelFilename(channel, 'DbmMarkovDB')
|
||||||
|
self.dbs[channel] = anydbm.open(filename, 'c')
|
||||||
self.dbs[channel]['lasts'] = ''
|
self.dbs[channel]['lasts'] = ''
|
||||||
self.dbs[channel]['firsts'] = ''
|
self.dbs[channel]['firsts'] = ''
|
||||||
return self.dbs[channel]
|
return self.dbs[channel]
|
||||||
@ -156,6 +157,7 @@ class MarkovWorkQueue(threading.Thread):
|
|||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
self.killed = True
|
self.killed = True
|
||||||
|
self.q.put(None)
|
||||||
|
|
||||||
def enqueue(self, f):
|
def enqueue(self, f):
|
||||||
self.q.put(f)
|
self.q.put(f)
|
||||||
@ -163,7 +165,8 @@ class MarkovWorkQueue(threading.Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
while not self.killed:
|
while not self.killed:
|
||||||
f = self.q.get()
|
f = self.q.get()
|
||||||
f(self.db)
|
if f is not None:
|
||||||
|
f(self.db)
|
||||||
self.db.close()
|
self.db.close()
|
||||||
|
|
||||||
class Markov(callbacks.Privmsg):
|
class Markov(callbacks.Privmsg):
|
||||||
|
Loading…
Reference in New Issue
Block a user