Reputation: 57
I have 1,000,000 records to process. if you use single code get 160,000 / day.
i want with python code 1,000,000 / day, what is the right function? (thread / multiprocesing / subprocess/ etc)
my single code :
result = cursor.fetchall()
def myProcces(id,data):
......
for row in result:
myProcces(row[0],row)
Upvotes: 0
Views: 304
Reputation: 91
Your choice of module should be based on the type of processing you mean to do using the code. Please elaborate on the type of task at hand a little further.
Multithreading: you should use this if the task at hand is I/O bound process like an API call/ request-response , involves some sleep or waiting time.
Multiprocessing : you should use this if the task at hand is more CPU intensive i.e. involves lot of calculation or CPU overhead.
Note: If you try to use multithreading for CPU intensive tasks then it will work with same performance as a single program would.
Upvotes: 2