moving to processing from threading, global variables
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--
http://mail.python.org/mailman/listinfo/python-list
Re: moving to processing from threading, global variables
no one? how can i share variables in processing? please help out! On Thu, Apr 9, 2009 at 8:05 AM, [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 processing.Process(target=sendalert).start() > if done and number_threads processing.Process(target=sendalert).start() > time.sleep(30) > > if __name__ == '__main__': > processing.Process(target=control).start() > -- http://mail.python.org/mailman/listinfo/python-list
spawning a process using os.spawn
hi im spawning a script that runs for a long from a web app like this: os.spawnle(os.P_NOWAIT, "../bin/producenotify.py", "producenotify.py", "xx",os.environ) the script is spawned and it runs, but till it gets over i am not able to free the port that is used by the web app, or in other words i am not able to restart the web app. how do i spawn off a process and make it completely independent of the web app? thanks -- http://mail.python.org/mailman/listinfo/python-list
