Global variables problem

Discussion in 'Python' started by Navkirat Singh, Aug 4, 2010.

  1. 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
     
    Navkirat Singh, Aug 4, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne
    Replies:
    2
    Views:
    485
    Wayne
    Nov 11, 2003
  2. jubelbrus
    Replies:
    5
    Views:
    631
    JohnQ
    Jul 20, 2007
  3. mark4asp
    Replies:
    1
    Views:
    225
  4. Tony Archer

    Global Variables? Multi-Application Variables?

    Tony Archer, Nov 24, 2003, in forum: ASP General
    Replies:
    5
    Views:
    231
    Tony Archer
    Nov 25, 2003
  5. king
    Replies:
    2
    Views:
    177
    Tad McClellan
    Jun 27, 2006
Loading...

Share This Page