Make pickle saving safer

Yes, I just hand-restored my corrupted pickle due to ENOSPC :-)
master
LEdoian 9 months ago
parent 341186773a
commit e1bea5a537

@ -8,6 +8,7 @@ from dataclasses import dataclass
from collections import defaultdict
from pathlib import Path
import traceback
import os
api_url = r'https://review.video.fosdem.org/api/v1/event/1/overview'
poll_rate = 10*60 # seconds
@ -59,7 +60,8 @@ def main():
traceback.print_exc()
# Save the pickle
# Should probably save elsewhere and do atomic rename, but whatever.
# Keep the previous pickle in case we fail (e.g. ENOSPC)
os.rename(pickle_file, pickle_file.with_suffix('.bak'))
with open(pickle_file, 'wb') as f:
pickle.dump(ts, f)
print('pickle saved')

Loading…
Cancel
Save