From 414be0405ecb09f4f732422c129e92dcdd59ae6a Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Sun, 15 Mar 2020 16:30:34 +0000 Subject: [PATCH] Added a note about concurrency --- openflexure_microscope/api/v2/views/streams.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openflexure_microscope/api/v2/views/streams.py b/openflexure_microscope/api/v2/views/streams.py index 4382e2ab..73ffd258 100644 --- a/openflexure_microscope/api/v2/views/streams.py +++ b/openflexure_microscope/api/v2/views/streams.py @@ -18,7 +18,16 @@ class MjpegStream(View): @doc_response(200, mimetype="multipart/x-mixed-replace") def get(self): """ - MJPEG stream from the microscope camera + MJPEG stream from the microscope camera. + + Note: While the code actually getting frame data from a camera and storing it in + camera.frame runs in a thread, the gen(microscope.camera) generator does not. + This response is therefore blocking. The generator just yields the most recent + frame from the camera object, passed to the Flask response, and then repeats until + the connection is closed. + + Without monkey patching with gevent, or using a native threaded server, the stream + will block all proceeding requests. """ microscope = find_component("org.openflexure.microscope") # Restart stream worker thread