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
202 views
in Technique[技术] by (71.8m points)

datafeed - pipe output from repeated function calls to python generator

I can't think of a better title to describe the problem but here it is.

I have a function that is called at random unscheduled intervals by a module which receives data.

There's another module that utilizes websockets and takes in data in the following method

def ws_handler(ws):
    for data in data_feed():
        ws.send(json.dumps(data)) 

and the data_feed periodically yields an output.

I can't figure out a way to replace the dummy data_feed() with the feed coming from the first module without hosting a local server with additional websockets or using multithreading. I feel like threading shouldn't be necessary as the process is linear and attempting with asyncio pipeline both increases delay and i cant figure out a way to execute async task immediately.

question from:https://stackoverflow.com/questions/65622967/pipe-output-from-repeated-function-calls-to-python-generator

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
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

2.1m questions

2.1m answers

60 comments

57.0k users

...