Python unit test multithreading

I am new to unit testing using the unit test module, and I need to test a class that uses the streaming module. I really have not found a solution on how best to use the class using streams. I start to check if the thread (i.e. Live) was called, but then I saw that there was no way to kill the thread. I need a week to make sure that the code in the thread does what it should do. Do I need to use a thread for this, or should I only test this function myself?

Thank you for your help!

Here is my code (interesting part):

class VideoLoader(Node):
   # some code

   def execute(self):
     self.thread1 = Thread(target = run_resizer, args = (self,))

def run_resizer(node):
    while True:
        while not len(node.frames_to_resize):
            time.sleep(0.001)      
        node.frames.append(resize({'height': 400, 'width': 500))
+4
source share

All Articles