Helper Utilities¶
The pydbzengine library provides a set of helper functions inside the Utils class (located in helper.py) to help manage the engine's lifecycle, run the engine asynchronously, or run until snapshots complete.
Methods Reference¶
Utils.run_engine_async¶
Runs the given engine's run method in a separate background thread with a maximum duration (timeout). If the engine exceeds the timeout limit, it raises a TimeoutError and calls engine.close().
@staticmethod
def run_engine_async(engine: DebeziumJsonEngine, timeout_sec: int = 22, blocking: bool = True)
engine: The DebeziumJsonEngine instance to execute.timeout_sec: The maximum execution time in seconds. Defaults to22.blocking: IfTrue, blocks the calling thread (e.g. main thread) usingjoin()until the engine completes or times out. Defaults toTrue.
Example Usage¶
from pydbzengine.helper import Utils
# Run the engine for exactly 60 seconds and then stop
Utils.run_engine_async(engine=engine, timeout_sec=60)
Utils.run_engine_until_snapshot¶
Runs the Debezium engine in a daemon thread and monitors logging outputs. Once the log message "Snapshot completed" is detected, the engine is shut down gracefully. This is extremely useful for loading initial tables/snapshots when using snapshot.mode = initial_only (or equivalent Debezium snapshot modes) in batched ingestion jobs.
engine: The DebeziumJsonEngine instance to execute.poll_interval_sec: The frequency (in seconds) to check log handlers for snapshot completion. Defaults to1.