# Path: il2fb/ds/airbridge/typing.py



import io
import logging
import threading
import time
from pathlib import Path
from os import stat_result
from ddict import DotAccessDict
from il2fb.ds.airbridge.typing import StringHandler, StringOrPath
        self._subscribers_lock = threading.Lock()

    def subscribe(self, subscriber: StringHandler) -> None:
        with self._subscribers_lock:
            self._subscribers.append(subscriber)

    def unsubscribe(self, subscriber: StringHandler) -> None:
        with self._subscribers_lock:
            self._subscribers.remove(subscriber)

    def stop(self) -> None:
        LOG.debug(f"ask watch dog for text file `{self._path}` to stop")

        with self._stop_lock:
            self._do_stop = True

    def run(self) -> None:
        try:
            LOG.info(f"watch dog for text file `{self._path}` was started")
            self._run_with_retries()
        except StopWatchDog:
            LOG.info(f"watch dog for text file `{self._path}` was stopped")
        except Exception:
            LOG.error(f"watch dog for text file `{self._path}` was terminated")
            raise

    def _run_with_retries(self) -> None:
        while True:
            self._maybe_stop()


# Path: il2fb/ds/airbridge/typing.py



# Path: il2fb/ds/airbridge/watch_dog.py
import io
import logging
import threading
import time
from pathlib import Path
from os import stat_result
from ddict import DotAccessDict
from il2fb.ds.airbridge.typing import StringHandler, StringOrPath

        self._subscribers_lock = threading.Lock()

    def subscribe(self, subscriber: StringHandler) -> None:
        with self._subscribers_lock:
            self._subscribers.append(subscriber)

    def unsubscribe(self, subscriber: StringHandler) -> None:
        with self._subscribers_lock:
            self._subscribers.remove(subscriber)

    def stop(self) -> None:
        LOG.debug(f"ask watch dog for text file `{self._path}` to stop")

        with self._stop_lock:
            self._do_stop = True

    def run(self) -> None:
        try:
            LOG.info(f"watch dog for text file `{self._path}` was started")
            self._run_with_retries()
        except StopWatchDog:
            LOG.info(f"watch dog for text file `{self._path}` was stopped")
        except Exception:
            LOG.error(f"watch dog for text file `{self._path}` was terminated")
            raise

    def _run_with_retries(self) -> None:
        while True:
            self._maybe_stop()


            try: