mpimentel04 / rtsp_fastapi

41 stars 9 forks source link

It seems to start new thread for every streaming request. is this correct ? #2

Closed dhruv-kabariya closed 2 years ago

dhruv-kabariya commented 2 years ago

@app.get("/keep-alive") def keep_alive(): global manager global count_keep_alive count_keep_alive = 100 if not manager: manager = Queue() p = Process(target=start_stream, args=(url_rtsp, manager,)) p.start() threading.Thread(target=manager_keep_alive, args=(p,)).start()

here we see that it start new thread for request. is this right ?

mpimentel04 commented 2 years ago

Hi @dhruv-kabariya

Yes, It's correct.

The function opens a separate process with a countdown and terminates the process after the countdown.

The Stream stays in memory and no matter how many calls you make on the index "/", it will only be consumed once.

dhruv-kabariya commented 2 years ago

@mpimentel04 Thank you for the quick replay. It solves my doubt.