I'm trying to understand what changed between python2 and python3 in the multiprocessing module. On python2 running this code works like a charm:
def RunPrice(items, price):
print("There is %s items, price is: %s" % (items, price))
def GetTargetItemsAndPrice(cursor):
res = cursor.execute("SELECT DISTINCT items, price FROM SELLS")
threads = []
for row in res.fetchall():
p = multiprocessing.Process(target=RunPrice, args=(row[0],row[1]))
threads.append(p)
p.start()
for proc in threads:
proc.join()
Let's say there is 2000 entries to be processed in SELLS. On python2 this script run and exit as expected. On python3 I get a:
File "/usr/lib/python3.8/multiprocessing/popen_fork.py", line 69, in _launch
child_r, parent_w = os.pipe()
OSError: [Errno 24] Too many open files
Any idea what happened between python2 and python3?
ulimit -a(on the shell)?Processobject for every entry. Create aPooland distribute the work.