I am trying to implement multiprocessing in my application.
The scenario is :
From GUI, when i click "Run" button control comes to a python function(which is not a main function).
Now in this function I am running loop and reading/executing multiple file one at a time. I want this to happen in parallel.
But as multiprocessing.process() need
__name__ ='__main__', my function mentioned in "
target = function name" in multiprocessing() is not being invoked.
How can I make it happen. If multiprocessing seems wrong way then any alternative way to improve code performance?
Adding Sample code(please note that this is just a psudo code where i have added high level code to understand the flow, please excuse any syntax error) :
from django.urls import path from textapp import views urlpatterns = [ path('execute/',views.functiontomultiprocess), ... other urls ]
def functiontomultiprocess(request): for doc in alldocs: p = multiprocess.Process(function2) p.start() p.join()