controller.utils.interruptor_watcher

File:

EuljiroWorship/controller/utils/interruptor_watcher.py

Author:

Benjamin Jaedon Choi - https://github.com/saintbenjamin

Affiliated Church:

The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]

Address:

The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea

Telephone:

+82-2-2266-3070

E-mail:

euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)

License:

MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.

Watches core.config.paths.VERSE_FILE and emits a Qt signal when the emergency text is cleared.

This module defines a lightweight polling watcher used by the slide controller. It monitors the emergency verse file (core.config.paths.VERSE_FILE) and detects the state transition from non-empty to empty. When that transition occurs, it emits InterruptorWatcher.interruptor_cleared, allowing the controller to restore the previous slide session and exit emergency mode.

Key behavior:

  • Polls the verse file at a configurable interval (poll_interval)

  • Emits a signal only on the transition: non-empty -> empty

  • Provides a stop mechanism for clean thread shutdown

class controller.utils.interruptor_watcher.InterruptorWatcher(*args, **kwargs)[source]

Bases: QObject

Monitors the emergency verse output file and emits a signal when it is cleared.

This watcher is designed to run inside a QThread loop (polling-based). It reads core.config.paths.VERSE_FILE periodically and tracks the last observed content. When the file transitions from non-empty content to an empty string, it emits interruptor_cleared.

interruptor_cleared

Emitted when the verse file becomes empty after previously containing text.

Type:

Signal

__init__(poll_interval=1)[source]

Initialize the watcher.

Parameters:

poll_interval (int | float) – Time in seconds between file polls.

Returns:

None

stop()[source]

Stop the watcher loop.

This method signals the polling loop in run() to exit cleanly. It is intended to be called during controller shutdown.

Parameters:

None

Returns:

None

run()[source]

Start monitoring the verse output file.

This method runs a polling loop while _running is True:

  • If the verse file exists, read and strip its content.

  • If the content transitions from non-empty to empty, emit interruptor_cleared.

  • Sleep for poll_interval seconds between polls.

Note

  • This is a polling-based watcher (not filesystem event-based).

  • Intended to be executed in a background QThread.

Parameters:

None

Returns:

None

restore_last_slide()[source]

Restore the previous slide state after emergency caption is cleared.

This is a thin helper that delegates restoration to controller.utils.slide_controller_data_manager.SlideControllerDataManager. It is not used directly by the watcher loop unless called externally.

Parameters:

None

Returns:

None