By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

Can thread start other threads?

P: n/a
Can Python thread start threads? It appears not. When I do that, the
sub-threads gets to certain point and just sit there. If I run the
code serially and not run the sub-thread code as threads, everything is
fine.

I throught the problem is when you run multiple processes of Pythons...

Jul 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
John Henry schrieb:
Can Python thread start threads? It appears not. When I do that, the
sub-threads gets to certain point and just sit there. If I run the
code serially and not run the sub-thread code as threads, everything is
fine.
It can.

import threading, time
class Test(threading.Thread):
def __init__(self, num):
threading.Thread.__init__(self)
self._num = num
self.setDaemon(True)
self.start()

def run(self):
if self._num 0:
t = Test(self._num - 1)
while True:
time.sleep(.2)
print "T_%i" % self._num
t = Test(4)

while True:
time.sleep(2.0)

I throught the problem is when you run multiple processes of Pythons...

No.

Whatever you do, it must be the cause. Without code - nobody can tell
you why.

Diez
Jul 18 '06 #2

P: n/a
Thanks for the confirmation.

I will see if I can reduce the code down to something managable and
post the failing code.

Diez B. Roggisch wrote:
John Henry schrieb:
Can Python thread start threads? It appears not. When I do that, the
sub-threads gets to certain point and just sit there. If I run the
code serially and not run the sub-thread code as threads, everything is
fine.

It can.

import threading, time
class Test(threading.Thread):
def __init__(self, num):
threading.Thread.__init__(self)
self._num = num
self.setDaemon(True)
self.start()

def run(self):
if self._num 0:
t = Test(self._num - 1)
while True:
time.sleep(.2)
print "T_%i" % self._num
t = Test(4)

while True:
time.sleep(2.0)

I throught the problem is when you run multiple processes of Pythons...


No.

Whatever you do, it must be the cause. Without code - nobody can tell
you why.

Diez
Jul 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.