s = "delete from kv where time < '%s';" % self.cut
c.execute(s)
self.next_expire = reactor.callLater(self.config['KE_DELAY'], self.doExpire)
+
+ def shutdown(self):
+ try:
+ self.next_expire.cancel()
+ except:
+ pass
num_contacts = reduce(lambda a, b: a + len(b.l), self.table.buckets, 0)
num_nodes = self.config['K'] * (2**(len(self.table.buckets) - 1))
return (num_contacts, num_nodes)
+
+ def shutdown(self):
+ """Closes the port and cancels pending later calls."""
+ self.listenport.stopListening()
+ try:
+ self.next_checkpoint.cancel()
+ except:
+ pass
+ self.expirer.shutdown()
+ self.store.close()
def krpc_ping(self, id, _krpc_sender):
sender = {'id' : id}
self.b = Khashmir(d)
def tearDown(self):
- self.a.listenport.stopListening()
- self.b.listenport.stopListening()
- try:
- self.a.next_checkpoint.cancel()
- except:
- pass
- try:
- self.b.next_checkpoint.cancel()
- except:
- pass
- try:
- self.a.expirer.next_expire.cancel()
- except:
- pass
- try:
- self.b.expirer.next_expire.cancel()
- except:
- pass
- self.a.store.close()
- self.b.store.close()
+ self.a.shutdown()
+ self.b.shutdown()
os.unlink(self.a.db)
os.unlink(self.b.db)
def tearDown(self):
for i in self.l:
- i.listenport.stopListening()
- try:
- i.next_checkpoint.cancel()
- except:
- pass
- try:
- i.expirer.next_expire.cancel()
- except:
- pass
- i.store.close()
+ i.shutdown()
os.unlink(i.db)
reactor.iterate()