title: how to stream multiple camera feeds to single socket in python
body: <p>I am working on a module where i have to detect some predefined objects in the video stream. For object detection i am using YOLO. 
  I need to process multiple camera feeds in parallel. I tried with multithreaded socket in python as discussed in <a href="https://stackoverflow.com/questions/23828264/how-to-make-a-simple-multithreaded-socket-server-in-python-that-remembers-client">this answer</a>. but it failed to handle multiple clients at same time. 
  Without sockets, i just tried with threads in python.</p>
  
  <pre><code>from concurrent.futures import ThreadPoolExecutor
  import threading
  import random
  import cv2
  from detection_image import get_detected_object
  import numpy as np
  import time
  
  def task(video_file):
      time.sleep(5)
      cap = cv2.VideoCapture(video_file)
      while True:    
          cap.set(1, frame_num)
          ret, frame = cap.read()
          ## Method to detect object in current frame.
          result = get_detected_object(frame)
  
  def main():
      executor = ThreadPoolExecutor(max_workers=2)
      task1 = executor.submit(task("1.mp4"))
      task2 = executor.submit(task("2.mp4"))
  
  if __name__ == '__main__':
      main() 
  </code></pre>
  
  <p>But this also doesnt seem to work. 
  I am thinking to create separate sockets for every camera and process the stream separately. Is this a correct way to do ?  or if multithreaded approach is correct, how can I achieve that ?</p>
  
  <p>Can anybody suggest ? </p>