python - Python3.4 : Multiprocessing variable functions -
i running code below using multiprocessing run ticker_list through request , parsing program faster. following code works, slow. not sure correct usage of multiprocessing. if there more efficient way please let me know.
ticker_list = [] open('/home/a73nk-xce/documents/python/sharkfin/sp500_fin/sp_stockchar/ticker.csv', 'r', newline='') csvfile: spamreader = csv.reader(csvfile) rows in spamreader: pass eachticker in rows: ticker_list.append(eachticker) def final_function(ticker): try: getfindata.cashdata(ticker_list) except exception e: pass if __name__ == '__main__': jobs = [] p = mp.process(target=final_function, args=(ticker_list,)) jobs.append(p) p.start() p.join()
if ticker file large (judging path name, may be)
using csv reader waste of time. not suport seek, way can last line
row in spamreader: pass since after "row" contain last row in file..
you can see here: most efficient way search last x lines of file in python it's possible retrieve last lines in file, , parse csv module afterward..
this save computation time..
Comments
Post a Comment