For performance improvement I tried to process multiple records at a time hence preferred multi threading. Each thread involves database connectivity and I am getting error like pymysql.err.InternalError: Packet sequence number wrong - got 48 expected 1
I have attached my code sample here. Any suggestions or real answers would help
items = items_array
if(items):
print(items);
ListOfProcesses = []
number_of_items = len(items)
processors = 20 # n of processors you want to use
parts = [items[i:i + processors] for i in range(0, len(items), processors)]
for part in parts:
for f in part:
p = Process(target=self.parallel_print, args=(f,))
p.start()
ListOfProcesses.append(p)
for p in ListOfProcesses:
p.join()
def parallel_print(self, item_code):
frappe.get_doc("Item", item_code)