Main thread stuck in Python Multithreading -



Main thread stuck in Python Multithreading -

i have 2 simple functions:

def run(self): # create 20 instances of clients , start in xrange(0,20): t = threading.thread(target = self.run_clients_in_seperate_threads()) t.start()

and

def run_clients_in_seperate_threads(self): print 'inside run_clients_in_seperate_threads' client_id = self.generate_client_id() cl = client(client_id) cl.start()

here, lastly line: cl.start() infinite loop.

i thinking main thread become free after starting kid threads, , hence spawn 20 threads in total. seems main thread waits after starting 1st thread.

can please explain i'm doing wrong ?

use target = self.run_clients_in_seperate_threads , pass self args parameter . way way invoke method in main thread , end infinite loop there : self.run_clients_in_seperate_threads != self.run_clients_in_seperate_threads()

python multithreading

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -