comect.sidecar.tailer module

class comect.sidecar.tailer.ThreadedTailer(path, callback)

Bases: object

A threaded logfile consumer. Spawns its own thread and uses it to tail a logfile.

Parameters
  • path (Path) – The path to the file that needs to be tailed

  • callback (Callable[[str], Any]) – A function to call with each line - will be called in the spawned thread

This class can be used to monitor multiple files at the same time - simply instantiate it for each file, and call start() when you’re ready to go.

Note that this will start a thread for every file you’re tailing, so be aware of thread count limits on whatever host you’re using this on.

property is_running

Returns True if the tailing thread is still running.

Return type

bool

mark_stop()

Set a flag to stop the thread - it will stop when the next line comes in.

start()

Start the thread, and begin tailing the file.