#StackBounty: #python #multithreading #optimization #parallel-processing #multiprocessing Multiprocessing in django and Python code

Bounty: 50

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) :

urls.py file:

from django.urls import path
from textapp import views

urlpatterns = [
    other urls


def functiontomultiprocess(request):
for doc in alldocs:
   p = multiprocess.Process(function2)

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.