title: How to safely Share videocapture from one webcam among 4 threads?
body: <p>I my Flask application I have 4 threads that run concurrently and all use same <code>cv2.videocapture(0)</code>, sometimes it works smoothly but I get this error most of the time</p>
  <pre class="lang-py prettyprint-override"><code>ret,self.frame = self.cap.read()
  cv2.error: OpenCV(4.0.1) C:\ci\opencv-suite_1573470242804\work\modules\videoio\src\cap_msmf.cpp:1082: error: (-215:Assertion failed) videoSample in function 'SourceReaderCB::Wait'
  </code></pre>
  <p>what does it mean? and how can I solve this problem?</p>
  <p>3 of the threads run at the same time for the whole duration, the fourth however starts and ends then restarts and ends and so on until all close at the same time.
  I don't know if this is threading problem as all threads operate in read only. If I need to implement something for synchronization how to make sure that fourth thread isn't starved?
  Pls note that I don’t implement threads but flask server handles each request in a separate thread. TIA</p>