Skip to content

Commit 0433add

Browse files
committed
Make use of pickle storage from datahandling.py in deletion watcher
1 parent ad4ebb7 commit 0433add

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

deletionwatcher.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# coding=utf-8
22
import json
33
import os.path
4-
import pickle
54
import requests
65
import time
76
import threading
@@ -19,6 +18,9 @@
1918
from tasks import Tasks
2019

2120

21+
PICKLE_FILENAME = "deletionIDs.p"
22+
23+
2224
# noinspection PyClassHasNoInit,PyBroadException,PyMethodParameters
2325
class DeletionWatcher:
2426
next_request_time = time.time() - 1
@@ -33,12 +35,11 @@ def __init__(self):
3335
log('error', 'DeletionWatcher failed to create a websocket connection')
3436
return
3537

36-
if os.path.exists("deletionIDs.p"):
37-
with open("deletionIDs.p", "rb") as fh:
38-
for post in DeletionWatcher._check_batch(pickle.load(fh)):
39-
self.subscribe(post, pickle=False)
40-
41-
self._save()
38+
if datahandling._has_pickle(PICKLE_FILENAME):
39+
pickle_data = datahandling._load_pickle(PICKLE_FILENAME)
40+
for post in DeletionWatcher._check_batch(pickle_data):
41+
self.subscribe(post, pickle=False)
42+
self._save()
4243

4344
threading.Thread(name="deletion watcher", target=self._start, daemon=True).start()
4445

@@ -113,8 +114,7 @@ def _save(self):
113114
else:
114115
pickle_output[post_site].append(post_id)
115116

116-
with open("deletionIDs.p", "wb") as pickle_file:
117-
pickle.dump(pickle_output, pickle_file)
117+
datahandling._dump_pickle(PICKLE_FILENAME, pickle_output)
118118

119119
@staticmethod
120120
def _check_batch(saved):

0 commit comments

Comments
 (0)