HealthCheck

class narupatools.core.health_check.HealthCheck

Base class for an object whose health can be checked.

Health checking is for objects which run tasks in the background, and is used to check if there has been an exception on any background threads.

Inheritance

Inheritance diagram of HealthCheck

Methods

__init__

Initialize self.

check_task

Check if a task has thrown an exception, and reraise it if so.

health_check

Check background tasks to ensure they have not encountered an exception.

__init__()

Initialize self. See help(type(self)) for accurate signature.

classmethod check_task(task: Optional[concurrent.futures._base.Future])None

Check if a task has thrown an exception, and reraise it if so.

Parameters

task – Background task to check for an exception.

health_check()None

Check background tasks to ensure they have not encountered an exception.

Calling this allows exceptions raised on background threads to be thrown on the main thread. It is a useful tool for checking if an object has crashed silently in the background.

It is recommended to call this periodically from the main thread to ensure an object is healthy. If no exceptions have occurred, this method will do nothing.