SyncDict

class SyncDict[source]

Bases: UserDict

Class for keeping json-backed dict with locking for sync

__init__(filename, lock=True)[source]

initialise empty ResultsDict :param filename: file to use for storage :param lock: set lock=False to avoid locking (use wisely)

Methods

__init__

initialise empty ResultsDict :param filename: file to use for storage :param lock: set lock=False to avoid locking (use wisely)

clear

copy

fromkeys

get

items

keys

load

restore results from file

pop

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem

as a 2-tuple; but raise KeyError if D is empty.

save

dump contents to json file

setdefault

update

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values

load()[source]

restore results from file

Returns:

populated ResultsDict

save()[source]

dump contents to json file

Parameters:

filename – output file path