Example #1
0
def save_storage(storage, filename):
    fp = None
    try:
        fp = portalocker.LockedFile(filename, 'wb')
        pickle.dump(dict(storage), fp)
    finally:
        if fp:
            fp.close()
Example #2
0
def load_storage(filename):
    fp = None
    try:
        fp = portalocker.LockedFile(filename, 'rb')
        storage = pickle.load(fp)
    finally:
        if fp:
            fp.close()
    return Storage(storage)