我在1秒钟内收到约20个值,如何设置我每秒接收1个值。
我尝试添加time.sleep(1),这些值会在1秒后出现,但是值会继续添加到队列中,即,当我停止流式传输时,值会继续出现。
from pythonosc import dispatcher
from pythonosc import osc_server
import time
def eeg_handler(unused_addr, args, ch1, ch2, ch3, ch4,ch5):
print(ch1)
ip = "192.168.43.197"
port = 5006
from pythonosc import osc_server, dispatcher
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/muse/eeg", eeg_handler, "EEG")
server = osc_server.ThreadingOSCUDPServer(
(ip, port), dispatcher)
# print("Serving on {}".format(server.server_address))
while True:
server.handle_request()
#time.sleep(1)
我希望当我开始流式传输时,我应该每秒从我的EEG设备接收1个值。