]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - apt_p2p/apt_p2p.py
Make the downloader statistics work.
[quix0rs-apt-p2p.git] / apt_p2p / apt_p2p.py
index 889ebd96243bddd83d77cafad10cec1504138abf..f88fd791a184fde37646501ea2fb941eb17e70fb 100644 (file)
@@ -88,8 +88,13 @@ class AptP2P:
         self.mirrors = MirrorManager(self.cache_dir)
         self.cache = CacheManager(self.cache_dir.child(download_dir), self.db, self)
         self.my_contact = None
+        reactor.addSystemEventTrigger('before', 'shutdown', self.shutdown)
 
-    #{ DHT maintenance
+    #{ Maintenance
+    def shutdown(self):
+        self.stats.save()
+        self.db.close()
+        
     def joinComplete(self, result):
         """Complete the DHT join process and determine our download information.