You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
734 B
Python

"""
采样器进程
"""
import queue
import threading
import time
from communication import exception
from communication.define import LOGGER
class SampleThread(threading.Thread):
def __init__(self, state):
threading.Thread.__init__(self, daemon=True)
self.queue = queue.Queue()
self.state = state
def run(self) -> None:
while True:
task = self.queue.get()
if hasattr(task, 'fetch') and callable(task.fetch):
try:
task.fetch(self.state)
except exception.SkError as e:
LOGGER.exception(e)
time.sleep(.1)
time.sleep(.1)
self.queue.put(task)