try finally doesn't
Colin Brown
cbrown at metservice.com
Wed Nov 26 17:07:01 EST 2003
"Rene Pijlman" <reply.in.the.newsgroup at my.address.is.invalid> wrote in
message news:214asv4cuppifk71are7unbam170fgregk at 4ax.com...
> Colin Brown:
> >When I run this code and then immediately do a Control-C, I do not get
the
> >'thread' printed?
>
> Output buffering. It does when you import sys and add sys.stdout.flush()
> after the print statement.
>
> --
> René Pijlman
Also when I run this on Win2K, I get:
C:\test>cmd
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\test>python -u t3b.py
C:\test>
-----------------------------------------
import thread, time, sys
def x():
try:
time.sleep(60)
finally:
print 'thread'
sys.stdout.flush()
thread.start_new_thread(x,())
time.sleep(5)
More information about the Python-list
mailing list