ThreadedStorage

  • full name: tenpy.tools.cache.ThreadedStorage

  • parent module: tenpy.tools.cache

  • type: class

Inheritance Diagram

Inheritance diagram of tenpy.tools.cache.ThreadedStorage

Methods

ThreadedStorage.__init__(worker, disk_storage)

ThreadedStorage.close()

Close opened files, free memory and clean up temporary files/directories.

ThreadedStorage.delete(key)

Interface for cleaning up a previously saved data from disk in subclasses.

ThreadedStorage.load(key)

Interface for loading data from disk in subclasses.

ThreadedStorage.open(disk_storage[, ...])

Setup and start a Worker subthread.

ThreadedStorage.preload(key)

Interface for preloading data into the given dictionary into.

ThreadedStorage.save(key, value)

Interface for saving data to disk in subclasses.

ThreadedStorage.subcontainer(name)

Create another instance of the same class saving in a subdirectory/subgroup.

Class Attributes and Properties

ThreadedStorage.trivial

Whether the storage is actually kept in memory, instead of saving to disk.

class tenpy.tools.cache.ThreadedStorage(worker, disk_storage)[source]

Bases: Storage

Wrapper around a Storage (or subclass) with thread-parallelization.

Use thread-based parallelism to avoid delays from disk input/output when caching.

Note

If you’re running TeNPy on a cluster, you should probably adjust the number of OMP threads, e.g. export OMP_NUM_THREADS=3 in your cluster submission scripts to one less thread, since this class adds an extra thread waiting for disk I/O.

Parameters:
  • worker (Group) – The hdf5 group in which data will be saved using save_to_hdf5() under the specified keys.

  • disk_storage (Storage) – Instance of one of the other storage classes to wrap around.

trivial = True

Whether the storage is actually kept in memory, instead of saving to disk.

classmethod open(disk_storage, max_queue_size=2)[source]

Setup and start a Worker subthread.

Parameters:

disk_storage (Storage) – Instance with methods for the actual disk I/O handling.

close()[source]

Close opened files, free memory and clean up temporary files/directories.

subcontainer(name)[source]

Create another instance of the same class saving in a subdirectory/subgroup.

This method allows multiple DictCache instance re-using open resources. Subcontainers will explicitly be closed when any of the parent containers (on which subcontainer() was called) is closed.

load(key)[source]

Interface for loading data from disk in subclasses.

preload(key)[source]

Interface for preloading data into the given dictionary into.

Only overridden in ThreadedStorage for thread-parallelized pre-loading; in other cases it does nothing.

save(key, value)[source]

Interface for saving data to disk in subclasses.

delete(key)[source]

Interface for cleaning up a previously saved data from disk in subclasses.