ExamCache#
- class pulserver.recon.ExamCache[source]#
Bases:
MutableMapping[Hashable,Any]Thread-safe store of artifacts shared by the series of one exam.
A value is disposed when replaced by another object, deleted, cleared, or when the cache closes: through the
cleanupstored with it, else itsclose()method when it has one. Disposal errors are logged, not raised. Reads and writes afterclose()raiseRuntimeError.With a
directory, every value stored is also written there with pickle, and a key this cache does not hold is read from there, so the caches of one exam in different processes share their values. A value read back is a copy, without thecleanupstored with it; a key or value that cannot be pickled is held by this cache alone. Closing leaves the directory as it is.- Parameters:
exam_id – Identifier of the owning exam.
directory – Directory the exam’s caches share;
Noneholds values in memory only. Its files are unpickled, so only the processes sharing the exam may write to it: the proxy creates it under a directory only its own user can open.
Examples
>>> import pulserver.recon as recon >>> cache = recon.ExamCache("exam-1") >>> cache["coil_maps"] = "maps" >>> "coil_maps" in cache, len(cache) (True, 1)
Methods
Dispose and remove every cached artifact, the directory's included. |
|
Dispose every artifact and retire the cache; repeated calls do nothing. |
|
Return the artifact at |
|
Remove and return an artifact without disposing it. |
|
as a 2-tuple; but raise KeyError if D is empty. |
|
Store an artifact and return it, disposing the value it replaces. |
|
If E present and has a .keys() method, does: for k in E.keys(): 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 |
|
Attributes
Whether |