Global variables problem

N

Navkirat Singh

Hey guys,

I am using a multiprocessing program, where the new process is supposed to change a variable in the main class that it branches out from. This is somehow not working, following is an approximate code. Would really appreciate any insight into this matter:


var = {}

class Something():

def set_var(self):
global var
var = somevalue

def get_var(self):
return var

def newprocess(self):
self.set_var()

def do_multiprocessing(self):
while true:
self.get_var()
new_process = process(target=newprocess)
new_process.start()


I am really confused here !

Any help would be awesome : )

Regards,
Nav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top