Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7072

`OSError: [Errno 24] Too many open files` with python3.12.3 multiprocessing on ubuntu 24.04 terminal

$
0
0

The following code always gives me the errorOSError: [Errno 24] Too many open fileswhen reaching 508 processes executed, which means every process leaves two file descriptors open, and then I reach the system's limit:

from multiprocessing import Processdef do_job(task):    print("Task no " + str(task))def main():    number_of_processes = 1000    processes = []    for i in range(number_of_processes):        p = Process(target=do_job, args=(i,))        processes.append(p)    # creating processes    for p in processes:        p.start()        p.join()    return Trueif __name__ == "__main__":    main()

If I try the same code on the vs code terminal then it completes with no issue. I looked at many similar online threads but yet to find a working solution.


Viewing all articles
Browse latest Browse all 7072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>