0

Hi I have the following code:

def record_video(task_id):    

    (
        ffmpeg
        .input('a.mp4', t=t)
        .output(f'{task_id}.mp4')
        .run()
    )


thread = Thread(target=record_video, args=(f'{uuid.uuid1()}.mp4'))

thread.start()

print('end job')

The idea is that print('end job') runs first, but anyway this waits until record_video thread ends, how can I solve this?

Thanks

Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84
  • Does this answer your question? [What is the global interpreter lock (GIL) in CPython?](https://stackoverflow.com/questions/1294382/what-is-the-global-interpreter-lock-gil-in-cpython) – tevemadar May 06 '22 at 16:17
  • https://docs.python.org/3/library/threading.html : *In CPython, due to the Global Interpreter Lock, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). If you want your application to make better use of the computational resources of multi-core machines, you are advised to use multiprocessing or concurrent.futures.ProcessPoolExecutor. However, threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously.* - yours is a case of "computational resources of multi-core machines". – tevemadar May 06 '22 at 16:20

0 Answers0