Fellow Pythonists; According to the docs
+-----------------+
|interrupt_main (|)|
+-----------------+
Raise a KeyboardInterru pt in the main thread. A subthread can use
this function to interrupt the main thread. New in version 2.3.
Therefore, I was expecting this short test prog to run and then finish
with the KeyboardInterru pt exception at the bottom in the pause
routine. It doesn't stop there but I can do a manual keyboard
interrupt and get the expected bactrace and program exit.
---
from signal import pause
from socket import socket
from thread import start_new_threa d, interrupt_main
from time import sleep
def go():
print 'go'
while f.readline():
print 'line'
print 'empty'
interrupt_main( )
print 'done'
s = socket()
s.connect(('loc alhost', 80))
f = s.makefile()
print 'connected'
start_new_threa d(go, ())
sleep(2)
s.shutdown(2)
pause() # expecting to get KeyboardInterru pt exception here
---
connected
go
empty
done
....hangs here as if interrupt_main( ) does nothing.
Manual Control-C required to wake up from pause() and exit.
Traceback (most recent call last):
File "test.py", line 23, in ?
pause() # expecting to get KeyboardInterru pt exception here
KeyboardInterru pt
Python 2.3.3 on RedHat 7x.
Wondering what's wrong?
Thanks
--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/