how to do multiprocessing in django from the inside of views.py?

时间:2019-01-09 22:10:54

标签: django django-views multiprocessing

I am trying to employ parallel processing in my Django web app. I am writing the multiprocessing code inside of the views.py, now I know i cannot write if name == main inside django. I did some research and got to know that, you can follow the below structure to go about incorporating multiprocessing inside views.py:

def my_func(args): ....code here....

def optimize(request): for i in range(0,process_list): p = process(target = my_func,args=(arg_list)) pros.append(p) p.start() for t in pros: t.join()

When I try the above code, i get an error at the line p.start() where it says errno32 broken pipe error. So how do I go about fixing it? Or is there any other module that i can use for multiprocessing?

0 个答案:

没有答案