need some help with threading module...

M.E.Farmer mefjr75 at hotmail.com
Mon Dec 27 15:22:41 EST 2004


chahnaz.ourzikene wrote:
> "M.E.Farmer" <mefjr75 at hotmail.com> a écrit dans le message de news:
> 1104102769.321923.4140 at z14g2000cwz.googlegroups.com...
>
> > Just a warning!
> > Threads and newbies don't mix well,
> > many pitfalls and hard to find bugs await you.
> > I would avoid using threads if at all possible.
>
> Indeed :). But how will i learn using threads if i avoid using them
:) ??
That was the point , you probably don't need them, and if so avoid
them.
If you want to learn how to use them , go for it!
That is an excellent reason to mess with them, it was just a warning
because you WILL be bitten by them, just a matter of time ;)

> > Now we have all that over lets see some code.
> >
> > py> import threading
> > py> class Test(threading.Thread):
> > ...        def run(self):
> > ...             x = 0
> > ...             while x < 10:
> > ...                 print x
> > ...                 x += 1
> > ...             print " Ending"
> > Use it like this:
> > py> Test().start()
>
> Your example is interristing...somehow this is not exactly what i
want to
> realise. I have exposed the problem in an earlier reply...
> Yacine Chaouche -- France.

I should have mentioned this was an attempt to show you how to make a
thread 'exit' after it reached 10. You are having problems with the
controller class, please look again at what I gave you this as an
example. Did you run it?
It was specific to your question. You were having problems making the
controller exit.
It should explain where you are lost, notice I inherit from Thread and
not object, notice a much simpler way to write the thread ....
You also mention the MVC pattern. If you are trying to implement MVC
with threads you are going about it the wrong way ;)
Hth,
M.E.Farmer




More information about the Python-list mailing list