Skip to content

trulens.core.utils.threading

trulens.core.utils.threading

Threading Utilities

Classes

Thread

Bases: Thread

Thread that wraps target with stack/context tracking.

App components that do not use this thread class might not be properly tracked.

ThreadPoolExecutor

Bases: ThreadPoolExecutor

A ThreadPoolExecutor that keeps track of the stack prior to each thread's invocation.

Apps that do not use this thread pool might not be properly tracked.

TP

Bases: SingletonPerName

Manager of thread pools.

Singleton.

Attributes
MAX_THREADS class-attribute instance-attribute
MAX_THREADS: int = 128

Maximum number of threads to run concurrently.

DEBUG_TIMEOUT class-attribute instance-attribute
DEBUG_TIMEOUT: Optional[float] = 600.0

How long to wait (seconds) for any task before restarting it.

Functions
warning
warning()

Issue warning that this singleton already exists.

delete_singleton_by_name staticmethod
delete_singleton_by_name(
    name: str, cls: Optional[Type[SingletonPerName]] = None
)

Delete the singleton instance with the given name.

This can be used for testing to create another singleton.

PARAMETER DESCRIPTION
name

The name of the singleton instance to delete.

TYPE: str

cls

The class of the singleton instance to delete. If not given, all instances with the given name are deleted.

TYPE: Optional[Type[SingletonPerName]] DEFAULT: None

delete_singleton
delete_singleton()

Delete the singleton instance. Can be used for testing to create another singleton.

__new__
__new__() -> TP

Override new of SingletonPerName to ensure valid typing of the TP object.

Functions