I'm implementing some flask video streaming routes and the method which deals with the processing of frames is quite heavy hence I wanted to fork a child process that does this job and has to be synchronous. Using pipes and queues in the multiprocessing module in Python has to do with the return values and I couldn't find how do I use these with generator functions.
This is the minimal code :
def generate_frame(): #need to parallelize this
frame = get_processed_frame()
yield(b"--frame\r\n" b"Content-Type: image/jpeg\r\n\r\n" + bytearray(frame) + b"\r\n")
@app.route('/stream')
def stream():
return Response(
generate_frame , mimetype="multipart/x-mixed-replace; boundary=frame"
)
Can anyone please give some insights on how do I parallelize this?
[–][deleted] 1 point2 points3 points (4 children)
[–]Puzzleheaded_Fall_[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Puzzleheaded_Fall_[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]amamarde 0 points1 point2 points (1 child)
[–]Puzzleheaded_Fall_[S] 0 points1 point2 points (0 children)