Starting threads -- solved

Lukas Kubin kubin at
Wed Jan 29 17:09:16 CET 2003

You are right. I did access the "comp" (containg hostname) variable
globally instead of use the form "classname.variablename" or "self.comp".
Yes, it's a beginners' fault. Don't laugh, please :) I'll do it no more
Thank anybody for trying to help me and sorry I've took your time.


On Wed, 29 Jan 2003, Peter Hansen wrote:

> Lukas Kubin wrote:
> >
> > It's been half a day since I sent a more describing response to the news.
> > Until now it didn't appear there. So I will try to be more clear now
> > again:
> > (I'm running it on linux and python 2.2.1)
> >
> > The main call looks like:
> >
> > if __name__ == '__main__':
> >
> >   for comp in ['hostname1','hostname2']:
> >     thread = Control(comp)
> >     thread.start()
> >     time.sleep(.005)
> >
> > The doTheAction() function uses socket to connect to a computer and send a
> > command there.
> > When I don't use the time.sleep() then it starts 2 threads of 'hostname2'
> > so it connects 2 times to hostname2 but not to hostname1.
> Please go back and read my first reply again.
> With the extra information (still minimal... please post doTheAction()!)
> you've provided, I'm now more convinced that my first guess was correct.
> You very likely have a code-reentrancy problem, possibly because you're
> using a global variable (?), which is causing the problem.
> The above code is certainly starting two threads.  The issue is how
> does the first thread hear about "hostname2" instead of "hostname1".
> The only likely answer is that you do not have thread-safe code.
> Please post doTheAction() if you can't find the problem yourself.
> Without it, we're stuck.
> -Peter

Lukas Kubin

phone: +420696398285
email: kubin at

Information centre
The School of Business Administration in Karvina
Silesian University in Opava
Czech Republic

More information about the Python-list mailing list