You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import multiprocessing
from multiprocessing import Pool
class pdf_gen():
def __init__(self):
pdf = self.pdf = FPDF()
pdf.set_auto_page_break(True,0.1)
def get_data_from_mysql(self) :
pdf = self.pdf
# connection is established and result is stored in 'res'.
dup = []
dup.insert(0,res)
z = tuple(dup)
return z
def mysql_to_pdf_data(self,*result) :
try :
pdf = self.pdf
# Entered data need to be in pdf
finally :
pdf.output('save_pdf.pdf','F')
def main() :
pdf = pdf_gen()
recover_data = pdf.get_data_from_mysql()
pool = multiprocessing.Pool(multiprocessing.cpu_count())
pool.map(pdf.mysql_to_pdf_data,recover_data)
Below picture shows that CPU was using only 1 core instead 2 were there.
The text was updated successfully, but these errors were encountered:
May be your recover_data.size is less than multiprocessing.cpu_count().
multiprocessing.cpu_count() is 8 in my own, when the size of get_data_from_mysql() return is less than 8, it depends on your data'size for your process
Below picture shows that CPU was using only 1 core instead 2 were there.
The text was updated successfully, but these errors were encountered: