99e1b82ea8
Integrated SalaryDetect class into the API and initiated an autonomous salary detection loop during the startup event. This enhancement improves the system's capability to monitor and analyze salary data in real-time.
33 lines
815 B
Python
33 lines
815 B
Python
import time
|
|
import logging
|
|
import threading
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class SalaryDetect:
|
|
def __init__(self):
|
|
self._running = False
|
|
self._thread = None
|
|
|
|
def _run(self):
|
|
while self._running:
|
|
logger.info(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] Detecting salary...")
|
|
time.sleep(1)
|
|
logger.info(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] Salary detection complete")
|
|
time.sleep(1)
|
|
|
|
def start(self):
|
|
if not self._running:
|
|
self._running = True
|
|
self._thread = threading.Thread(target=self._run, daemon=True)
|
|
self._thread.start()
|
|
|
|
def stop(self):
|
|
self._running = False
|
|
if self._thread:
|
|
self._thread.join()
|
|
|
|
|
|
|