MainThread blocks all others
Nodir Gulyamov
gelios at rbcmail.ru
Wed Aug 10 09:47:13 EDT 2005
Hi again, comments below:
> > doSomeJob(self):
> > ##### BLOCKING HERE ###
> > if not self.myEvent.isSet():
> > self.myEvent.wait()
>
> The initial 'if' is superflous.
Excuse me, please explain.
> > self.myEvent.clear()
> > # ... continue...
> >
> > # this class subscribed to some observer which implements thread
> > class monitor:
> > def __init__(self, klass):
> > #do some init
> > self.c = klass
> > def update(self):
> > self.c.increaseCounter()
> >
> > if __name__ == "__main__":
> > cl1 = class1()
> > m = monitor(cl1)
> > mo = MonitorObserver(m)
>
> Obviously that won't work. You only have one thread, and it blocks
> in doSomeJob, so no one can ever trigger the even.
Actually I have 2 threads. One of them is MainThread and second one is
created by Observer in which update method called.
More information about the Python-list
mailing list