Auto Reset Timer

class thread_factory.utilities.timing_tools.auto_reset_timer.AutoResetTimer(interval_sec, callback, daemon=True)[source]

Bases: IDisposable

  • Automatically restarts after each invocation.

  • Thread-safe and supports graceful shutdown.

  • Exceptions in the callback are caught and logged.

  • Timer runs as a daemon by default.

dispose()[source]

Dispose of the timer and stop any scheduled execution. This should be called to clean up the timer when no longer needed.

is_running()[source]

Check if the timer is currently active.

Returns:

True if running, False otherwise.

Return type:

bool

restart()[source]

Stops and restarts the timer. Useful if you want to rearm it manually.

start()[source]

Starts the timer. If it’s already running, this does nothing.

stop()[source]

Stops the timer. The callback will no longer be invoked. If the timer is already stopped, this is a no-op.