HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/watchdog/utils/process_watcher.py
from __future__ import annotations

import logging

from watchdog.utils import BaseThread

logger = logging.getLogger(__name__)


class ProcessWatcher(BaseThread):
    def __init__(self, popen_obj, process_termination_callback):
        super().__init__()
        self.popen_obj = popen_obj
        self.process_termination_callback = process_termination_callback

    def run(self):
        while True:
            if self.popen_obj.poll() is not None:
                break
            if self.stopped_event.wait(timeout=0.1):
                return

        try:
            self.process_termination_callback()
        except Exception:
            logger.exception("Error calling process termination callback")