Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

python - I would like to send a data diffrent ways in SSE

Now I'm sending data to client by Server Side Event

Can I seperate these data.

enter image description here

such as

sent data: 1.8 sent data: -7.3 sent data: 4.5

My code:

def cal_fft(name):
    print("Starting " + name)
    gevent.sleep(5)
    while True:
        n = len(y)        # Length of signal
        NFFT = n      # ?? NFFT=2^nextpow2(length(y))  ??
        k = np.arange(NFFT)
        f0 = k*Fs/NFFT    # double sides frequency range
        f0 = f0[range(math.trunc(NFFT/2))]        # single sied frequency range

        Y = np.fft.fft(y)/NFFT        # fft computing and normaliation
        Y = Y[range(math.trunc(NFFT/2))]          # single sied frequency range
        #amplitude_Hz = 2*abs(Y)
        phase_ang = np.angle(Y) * 180 / np.pi
        q.put(phase_ang)
        gevent.sleep(2)
        
def stream_data():
    print("Starting streaming")
    while True:
        if not q.empty():
            result = q.get()
            print("sent data: ", result)
            # print(result)
            # yield 'event: fft
'
            yield 'data: % s

' % str(result)
            gevent.sleep(0.4)
        else:
            print("QUEUE empty!! Unable to stream @", time.ctime())
            gevent.sleep(1)  # Try again after 1 sec
            # os._exit(1)
question from:https://stackoverflow.com/questions/65839794/i-would-like-to-send-a-data-diffrent-ways-in-sse

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...