Unexpected (?) Thread behaviour
Vincent Berg
gorny0 at zonnet.nl
Sat May 3 05:45:11 EDT 2003
Peter Hansen <peter at engcorp.com> wrote in message news:<3EB33EB0.65567AA5 at engcorp.com>...
> > So my actual question is: why doesn't the run() method notices that
> > self.clients is updated?? Shouldn't it notice it??
>
> Well, what you think is happening probably is not. Certainly the code
> you posted should show that self.clients is getting appended to. Why
> do you think it is not?
I've put print statements before, after the if-statement and after
appending
to self.clients.
> Have you tried inserting a print statement
> in the while loop after the if, to show what self.clients contains just
> before the select statement?
That's part of the problem. It doesn't get past the if, since the
if-condition
seems to be invalid the whole time. So I can put a print statement
there but
it won't show a thing since it's never reached. Btw. I normally place
print statements all over the place when debugging a program, but I
removed them cause I didn't want to paste lots of code.
Aaargh... I finally found the problem. I've put a print statement in
the constructor and it seemed to be called twice as much as the number
of threads I was creating. I was so sure the problem should lie in
this class (since I didn't have much threads experience in Python). So
the actual thread running wasn't getting an update self.clients while
the not-started-thread got all the clients. This is by far the
stupidiest programming mistake I've made the past half year ;-)
But it's fixed now. Thanks for your reply.
Cheers,
Vincent Berg
More information about the Python-list
mailing list