no one? how can i share variables in processing?
please help out!
On Thu, Apr 9, 2009 at 8:05 AM, [email protected] <[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 in sendalert
> method, is not reflected in the controller method.
>
> can please point out what is wrong?
> thanks a lot!
>
>
> code
>
>
> done = False
> def sendalert():
> global done
> users = q.get('xx')
> if not users:
> done = True
> return
>
> done = False
> for u in users:
> do stuff
>
>
> def 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