[Python-checkins] python/dist/src/Lib dummy_thread.py,1.2,1.3
bcannon@users.sourceforge.net
bcannon@users.sourceforge.net
Fri, 13 Jun 2003 16:44:37 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv14872/Lib
Modified Files:
dummy_thread.py
Log Message:
dummy_thread modified to have interrupt_main and to behave appropriately when
called.
Added announcement in Misc/NEWS for thread.interrupt_main and mention of
dummy_thread's change.
Index: dummy_thread.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dummy_thread.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** dummy_thread.py 29 Jan 2003 03:49:43 -0000 1.2
--- dummy_thread.py 13 Jun 2003 23:44:35 -0000 1.3
***************
*** 18,22 ****
# (skipping obsolete synonyms allocate(), start_new(), exit_thread())
__all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock',
! 'LockType']
import traceback as _traceback
--- 18,22 ----
# (skipping obsolete synonyms allocate(), start_new(), exit_thread())
__all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock',
! 'interrupt_main', 'LockType']
import traceback as _traceback
***************
*** 37,40 ****
--- 37,43 ----
by using traceback.print_exc().
+ If the executed function calls interrupt_main the KeyboardInterrupt will be
+ raised when the function returns.
+
"""
if type(args) != type(tuple()):
***************
*** 48,51 ****
--- 51,58 ----
except:
_traceback.print_exc()
+ if _interrupt:
+ global _interrupt
+ _interrupt = False
+ raise KeyboardInterrupt
def exit():
***************
*** 115,116 ****
--- 122,132 ----
def locked(self):
return self.locked_status
+
+
+ _interrupt = False
+
+ def interrupt_main():
+ """Set _interrupt flag to True to have start_new_thread raise
+ KeyboardInterrupt upon exiting."""
+ global _interrupt
+ _interrupt = True