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.
29 lines
739 B
Python
29 lines
739 B
Python
2 years ago
|
"""
|
||
|
采样器进程
|
||
|
"""
|
||
|
import queue
|
||
|
import threading
|
||
|
import time
|
||
|
|
||
|
from Agreement.SM.skio import exception
|
||
|
from Agreement.SM.skio.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)
|