From 5060c5e005463e981773e3a39e3869504bd6a6f1 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Sun, 8 Sep 2024 07:02:22 +0300 Subject: [PATCH] No more pickling objects --- minode/manager.py | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/minode/manager.py b/minode/manager.py index 790bb80..b483129 100644 --- a/minode/manager.py +++ b/minode/manager.py @@ -22,7 +22,7 @@ class Manager(threading.Thread): self.q = queue.Queue() self.last_cleaned_objects = time.time() self.last_cleaned_connections = time.time() - self.last_pickled_objects = time.time() + # self.last_pickled_objects = time.time() self.last_pickled_nodes = time.time() # Publish destination 5-15 minutes after start self.last_published_i2p_destination = \ @@ -137,18 +137,6 @@ class Manager(threading.Thread): @staticmethod def load_data(): """Loads initial nodes and data, stored in files between sessions""" - try: - with open( - os.path.join(shared.data_directory, 'objects.pickle'), 'br' - ) as src: - for obj in pickle.load(src): - shared.objects[obj.vector] = obj - except FileNotFoundError: - pass # first start - except Exception: - logging.warning( - 'Error while loading objects from disk.', exc_info=True) - try: with open( os.path.join(shared.data_directory, 'nodes.pickle'), 'br' @@ -188,17 +176,17 @@ class Manager(threading.Thread): (row[0].encode(), 'i2p') for row in reader} shared.i2p_node_pool.update(shared.i2p_core_nodes) - @staticmethod - def pickle_objects(): - try: - with open( - os.path.join(shared.data_directory, 'objects.pickle'), 'bw' - ) as dst: - with shared.objects_lock: - pickle.dump(shared.objects, dst, protocol=3) - logging.debug('Saved objects') - except Exception: - logging.warning('Error while saving objects', exc_info=True) + # @staticmethod + # def pickle_objects(): + # try: + # with open( + # os.path.join(shared.data_directory, 'objects.pickle'), 'bw' + # ) as dst: + # with shared.objects_lock: + # pickle.dump(shared.objects, dst, protocol=3) + # logging.debug('Saved objects') + # except Exception: + # logging.warning('Error while saving objects', exc_info=True) @staticmethod def pickle_nodes():