Skip to navigation
How to do multiprocessing from python classes and modules methods
04.11.15
example: you have a class calles Controller, there it open modules like back_order or ctlg_catalog and than finally it calls the method like supplier_noninh_report or all_style_report and it gives some parameters like FOO work = [ ['back_order',"supplier_noninh_report",''], ['ctlg_catalog','all_style_report','Foo'], ] def worker(m,f,a): try: task = m+'.'+f print("Start:\t"+task) app = Controller(None) mo = getattr(app,m) func = getattr(mo,f) if(a == ''): func() else: func(a) except Exception as e: app._send_error(e,task) return jobs = [] for i in work: print(i) p = multiprocessing.Process(target=worker,args=(i[0],i[1],i[2],)) jobs.append(p) time.sleep(1) p.start()
https://pymotw.com/2/multiprocessing/basics.html
Reply
Anonymous
Information Epoch 1732592219
Think hierarchically.
Home
Notebook
Contact us