Curses and Threading

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Jan 21 20:49:06 EST 2008


En Mon, 21 Jan 2008 23:06:10 -0200, <Brett.Friermood at gmail.com> escribió:

> I am writing a program that uses curses and threading. I am working on
> displaying a clock in the upper right hand corner of the screen. I
> have only one thread at the moment, that gets the time and displays it
> in curses.

In fact you have *two* threads: the main thread, and the one you create  
explicitely.

> To make it easier to debug right now, the program starts
> curses in a try: clause then starts the thread which runs for 10
> iterations displaying the time every second. Then the thread exits,
> and the program is supposed to run the finally: clause to clean up the
> terminal.

After you start the clock thread, the main thread continues executing,  
immediately entering the finally clause.
If you want to wait for the other thread to finish, use the join() method.
But I'm unsure if this is the right way to mix threads and curses.

-- 
Gabriel Genellina




More information about the Python-list mailing list