0

I have 2 target multiprocessing function and I have passed dictionary in them as argument but the data inside that is not changing after the functions completes. please help me regarding this. in simple words I want to pass dictionary as reference in multiprocessing functions.

code

if __name__ == '__main__':

    all_repo_data = {} #this is that dictionary

    repos_data = total_repo_fetch(data, total_repos)
    fetch_repo_info(all_repo_data, repos_data, total_stars,)

    
    f1 = multiprocessing.Process(target = total_commit_fetch,args = (all_repo_data,))

    
    f3 = multiprocessing.Process(target=total_contributors, args=(all_repo_data,))

    f1.start()
    f3.start()
    f3.join()
    f1.join()

f1 function

def total_commit_fetch(all_repo_data):
        #some work ..... 
        #changing the value of all_repo_data dictionary....
        all_repo_data[(repo)]['total_commits'] = total_commit

but after the function complete dictionary is same as before and 'total_commits' is not available and data is lost.

lex
  • 23
  • 6
  • 1
    You previously posted a similar question using a *managed* dictionary. That is what you need to use because any regular dictionary you pass to another process is just being copied from one address space to another and it's the copy that is being modified. You might as well delete this post. I am sure this is a duplicate of 1,000,000 similar posts. I will look more closely at the other post. – Booboo Oct 16 '21 at 12:09

0 Answers0