undr.persist#

Progress storage utility.

Overview#

Classes#

Progress

Message that indicates that the given resource has been persisted.

ReadOnlyStore

Stores the IDs of processed tasks.

Store

Stores the IDs of processed tasks.

Attributes#

Module Contents#

class undr.persist.Progress#

Message that indicates that the given resource has been persisted.

path_id: pathlib.PurePosixPath#

The resource’s unique path ID.

class undr.persist.ReadOnlyStore(path: str | os.PathLike)#

Stores the IDs of processed tasks.

This store provides a method to check whether a task has been performed but it cannot be modified. Most users will probably prefer the writable Store.

Parameters:

path (Union[str, os.PathLike]) – Path of the SQLite database file with extension “.db”.

__contains__(id: str)#

Whether the given ID has been processed.

Parameters:

id (str) – The ID to check.

Returns:

True if the file is in the store, which means that it has been processed.

Return type:

bool

__enter__()#

Enables the use of the “with” statement.

Returns:

A store context that calls close() on exit.

Return type:

Display

__exit__(type: Type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None)#

Enables the use of the “with” statement.

Parameters:
  • type (Optional[Type[BaseException]]) – None if the context exits without an exception, and the raised exception’s class otherwise.

  • value (Optional[BaseException]) – None if the context exits without an exception, and the raised exception otherwise.

  • traceback (Optional[types.TracebackType]) – None if the context exits without an exception, and the raised exception’s traceback otherwise.

__getstate__()#

Helper for pickle.

__setstate__(state: pathlib.Path)#
close()#

Closes the store’s database.

class undr.persist.Store(path: str | os.PathLike, commit_maximum_delay: float = 0.1, commit_maximum_inserts: int = 100)#

Bases: ReadOnlyStore

Stores the IDs of processed tasks.

Parameters:
  • path (Union[str, os.PathLike]) – Path of the SQLite database file with extension “.db”.

  • commit_maximum_delay (float, optional) – How often changes are commited to the disk, in seconds. Defaults to 0.1.

  • commit_maximum_inserts (int, optional) – Maximum number of changes before commiting changes to the disk. Defaults to 100.

class Commit#

Message requesting a commit (changes are immediately persited to the disk).

class Reset#

Message requesting a reset of the database (existing entries are dropped).

__getstate__()#

Helper for pickle.

__setstate__(state: Tuple[pathlib.Path, int, int])#
add(id: str)#

Adds a row to the database.

The action is ignored if the entry is already in the database.

Parameters:

id (str) – Entry to store in the database.

close()#

Closes the store’s database.

commit()#

Immediately persists changes to the disk.

reset()#

Drops all entries from the database.

target()#

Worker thread implementation.

undr.persist.test_ids#