mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
Merge pull request #1087 from tahoe-lafs/3741.pickle-versioning-python-3
Limit Pickle protocol to version supported by Python 2 Fixes ticket:3741
This commit is contained in:
commit
de76c1d8ef
@ -201,7 +201,9 @@ class CPUWatcher(service.MultiService, resource.Resource, Referenceable):
|
||||
log.msg("error reading process %s (%s), ignoring" % (pid, name))
|
||||
log.err()
|
||||
try:
|
||||
pickle.dump(self.history, open("history.pickle.tmp", "wb"))
|
||||
# Newer protocols won't work in Python 2; when it is dropped,
|
||||
# protocol v4 can be used (added in Python 3.4).
|
||||
pickle.dump(self.history, open("history.pickle.tmp", "wb"), protocol=2)
|
||||
os.rename("history.pickle.tmp", "history.pickle")
|
||||
except:
|
||||
pass
|
||||
|
0
newsfragments/3741.minor
Normal file
0
newsfragments/3741.minor
Normal file
@ -252,7 +252,9 @@ class ShareCrawler(service.MultiService):
|
||||
self.state["last-complete-prefix"] = last_complete_prefix
|
||||
tmpfile = self.statefile + ".tmp"
|
||||
with open(tmpfile, "wb") as f:
|
||||
pickle.dump(self.state, f)
|
||||
# Newer protocols won't work in Python 2; when it is dropped,
|
||||
# protocol v4 can be used (added in Python 3.4).
|
||||
pickle.dump(self.state, f, protocol=2)
|
||||
fileutil.move_into_place(tmpfile, self.statefile)
|
||||
|
||||
def startService(self):
|
||||
|
@ -95,7 +95,9 @@ class LeaseCheckingCrawler(ShareCrawler):
|
||||
if not os.path.exists(self.historyfile):
|
||||
history = {} # cyclenum -> dict
|
||||
with open(self.historyfile, "wb") as f:
|
||||
pickle.dump(history, f)
|
||||
# Newer protocols won't work in Python 2; when it is dropped,
|
||||
# protocol v4 can be used (added in Python 3.4).
|
||||
pickle.dump(history, f, protocol=2)
|
||||
|
||||
def create_empty_cycle_dict(self):
|
||||
recovered = self.create_empty_recovered_dict()
|
||||
@ -319,7 +321,9 @@ class LeaseCheckingCrawler(ShareCrawler):
|
||||
oldcycles = sorted(history.keys())
|
||||
del history[oldcycles[0]]
|
||||
with open(self.historyfile, "wb") as f:
|
||||
pickle.dump(history, f)
|
||||
# Newer protocols won't work in Python 2; when it is dropped,
|
||||
# protocol v4 can be used (added in Python 3.4).
|
||||
pickle.dump(history, f, protocol=2)
|
||||
|
||||
def get_state(self):
|
||||
"""In addition to the crawler state described in
|
||||
|
Loading…
Reference in New Issue
Block a user