Make sure the MarkovWorkQueue dies.

This commit is contained in:
Jeremy Fincher 2004-08-17 16:18:59 +00:00
parent 451e083aec
commit 0bdbae6e47
1 changed files with 5 additions and 2 deletions

View File

@ -90,7 +90,8 @@ class DbmMarkovDB(object):
def _getDb(self, channel):
if channel not in self.dbs:
# 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]['firsts'] = ''
return self.dbs[channel]
@ -156,6 +157,7 @@ class MarkovWorkQueue(threading.Thread):
def die(self):
self.killed = True
self.q.put(None)
def enqueue(self, f):
self.q.put(f)
@ -163,7 +165,8 @@ class MarkovWorkQueue(threading.Thread):
def run(self):
while not self.killed:
f = self.q.get()
f(self.db)
if f is not None:
f(self.db)
self.db.close()
class Markov(callbacks.Privmsg):