Sleep timer but still responsive?

2010-01-28 Thread JohnnyFive
I need help with something that is probably fairly simple, but i'm
having a heck of a time getting it work.

Basically, I need my program to sleep for a certain amount of time,
but I don't want the console to become unresponsive while sleeping.

As soon as the time is up, I want the main program to run it's course
again.

I tried using a Timer, threads, etc, but I really can't figure it out.
What am I missing?

I can post what I have, but I don't want to get caught up on how i'm
doing it wrong (as none of it works), but rather the correct way to do
it.

Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sleep timer but still responsive?

2010-01-29 Thread JohnnyFive
On Jan 28, 4:55 pm, "Gabriel Genellina" 
wrote:
> Please provide more details. What do you want your program to do while  
> sleeping? What kind of actions do you want a response to?
> Do you have a GUI? A curses-based interfase?
>
> --
> Gabriel Genellina

My app is purely console based. I just don't want the console to lock
up (on Windows using time.sleep(x) causes the console to become
unresponsive until the timer is done), and I want people to be able to
CTRL+C to stop the script if need be (which can't be done if it's
unresponsive!).

Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sleep timer but still responsive?

2010-01-29 Thread JohnnyFive
On Jan 29, 9:33 am, Andreas Tawn  wrote:
> > On Jan 28, 4:55 pm, "Gabriel Genellina" 
> > wrote:
> > > Please provide more details. What do you want your program to do
> > while
> > > sleeping? What kind of actions do you want a response to?
> > > Do you have a GUI? A curses-based interfase?
>
> > > --
> > > Gabriel Genellina
>
> > My app is purely console based. I just don't want the console to lock
> > up (on Windows using time.sleep(x) causes the console to become
> > unresponsive until the timer is done), and I want people to be able to
> > CTRL+C to stop the script if need be (which can't be done if it's
> > unresponsive!).
>
> > Thanks.
>
> How about this? Responds to ctrl+c, but still sleeps.
>
> import time
>
> def responsiveSleep(n):
>     while n > 0:
>         time.sleep(1)
>         n -= 1
>
> Cheers,
>
> Drea

Thanks for the ideas! Maybe it's just my computer, but using your
solution still causes the prompt to become unresponsive during the
sleeps.

I am using 2.6.4 btw. It's not a major deal though, I just thought
there had to be a way to do this fairly easily.
-- 
http://mail.python.org/mailman/listinfo/python-list


Is there a way to see why a thread is still open?

2010-06-16 Thread JohnnyFive
I've got a rather complex program that, for some reason, is not
closing the completed threads when they are finished.

Just to cover my bases, when using the following:

temp = threading.Thread(target=self.processMessages,
args=(msg, args), name="pubmsg subthread")
temp.setDaemon(1)
temp.start()

What I understand is that when 'temp' is done processing, (and there's
no timers or anything, it just processes a message and goes through a
few routines afterwards, but nothing that is a loop/while/or anything
like that), then 'temp' should close on it's own.

So I obviously have something in my code that is keeping the thread
open, but I can't figure out what.

Is there a way to figure out why a thread is staying open? A utility,
or coding trick that I don't know about?

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list