[email protected] wrote:
no one?
It's Easter! :-)
how can i share variables in processing? please help out!
Threads run in the same address space, so they can share variables; processes run in different address spaces, so they can't (normally). You'll need to read the documentation carefully to see what the recommended techniques are (and I doubt that sharing a global Boolean variable is one of them...).
On Thu, Apr 9, 2009 at 8:05 AM, [email protected] <mailto:[email protected]> <[email protected] <mailto:[email protected]>> wrote:hi i am trying to move from threading to processing package. this is the controller i used to spawn new threads, and it used the global variable done to check if it needs to spawn more threads or not. it worked great for me. it checks if there is new data to be processed every 30 seconds, and spawns of new threads to do the work, till all work is done.but now in processing, anychange made to global variable done insendalert method, is not reflected in the controller method.can please point out what is wrong?thanks a lot!code done = Falsedef sendalert(): global done users = q.get('xx') if not users: done = True returndone = Falsefor u in users: do stuffdef control(number_threads_min=3, number_threads_max = 100):global done while True: number_threads = len(processing.activeChildren()) if not done and number_threads<number_threads_max: processing.Process(target=sendalert).start() if done and number_threads<number_threads_min: processing.Process(target=sendalert).start() time.sleep(30)if __name__ == '__main__':processing.Process(target=control).start() ------------------------------------------------------------------------ -- http://mail.python.org/mailman/listinfo/python-list
-- http://mail.python.org/mailman/listinfo/python-list
