Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

threads problem in python

0 views
Skip to first unread message

Astan Chee

unread,
May 13, 2008, 5:42:13 AM5/13/08
to pytho...@python.org
Hi,
I have 2 classes in python, the first one runs first and and then the
first one calls the second class. I want it to run the second class as a
separate thread but I want the first one to wait until the second class
is dead.
Im having problem in both killing the second class when its done and
making the first class wait for it to finish.
Im very confused on doing threads in python.
Thanks for any help.
Astan

--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose two."


Animal Logic
http://www.animallogic.com

Please think of the environment before printing this email.

This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free.

Gabriel Genellina

unread,
May 13, 2008, 6:38:40 AM5/13/08
to pytho...@python.org
En Tue, 13 May 2008 06:42:13 -0300, Astan Chee <st...@al.com.au> escribió:

> I have 2 classes in python, the first one runs first and and then the
> first one calls the second class. I want it to run the second class as a
> separate thread but I want the first one to wait until the second class
> is dead.
> Im having problem in both killing the second class when its done and
> making the first class wait for it to finish.
> Im very confused on doing threads in python.

I'm confused trying to understand your requirements too. "run a class?"
Threads execute code, it's easier to think of them as *functions* that are
executed at the same time (or almost).
So you have a function A that runs first, and creates a second thread that
will execute function B. Then A will wait for B to finish. What do you
want to do in A while it's waiting? Nothing? Then why to use a second
thread? Or is it a graphical interfase? GUI libraries like wxPython, Qt
and others have specific ways to execute backgroung tasks while keeping
the user interface responsive - you should tell us which one you're using
in that case.

--
Gabriel Genellina

casti...@gmail.com

unread,
May 13, 2008, 9:29:52 AM5/13/08
to
On May 13, 5:38 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:

I don't mean to be impertinent, but are you making any cents with the
assignment? Both free-ers and workers come in here. I am a free-er
who has reason to doubt that money-driven programs get stuck at that
kind of ambiguity. I hold that money keeps you out of that mess.

However, there are a number of things we can do to help, but as I, per
se, am only one person, I may not give you the best advice to start
with. How do you find the 'threading.py' docs?

Gabriel Genellina

unread,
May 14, 2008, 2:26:41 AM5/14/08
to pytho...@python.org
En Tue, 13 May 2008 20:46:51 -0300, Astan Chee <st...@al.com.au> escribió:

> Sorry, I mean functions not classes. Well, actually, one is a class and
> another is a function. So when the script (its a free game btw) runs, it
> instantiates the first class and somewhere in the middle of processing
> the first class, I need to call a function as a separate thread, I also
> want to wait for the function to complete and I was wondering how python
> handles the thread of this function? Does it die when the function
> completes? Anyway, I know it sounds silly to have 2 threads when I can
> do it with one, but Im using wx to render opengl objects using pygame.
> So it has to be a separate thread, otherwise wx wont play nice. Is there
> a simple example of how I can do this?

That's why I asked about the GUI library used. For wx see
http://wiki.wxpython.org/LongRunningTasks

--
Gabriel Genellina

0 new messages