[Python-checkins] python/dist/src/Lib dummy_thread.py,1.3,1.4

bcannon@users.sourceforge.net bcannon@users.sourceforge.net
Fri, 13 Jun 2003 16:56:34 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv17013/Lib

Modified Files:
	dummy_thread.py 
Log Message:
Cause calling interrupt_main in main thread raise KeyboardInterrupt instantly.

Index: dummy_thread.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dummy_thread.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dummy_thread.py	13 Jun 2003 23:44:35 -0000	1.3
--- dummy_thread.py	13 Jun 2003 23:56:32 -0000	1.4
***************
*** 45,48 ****
--- 45,50 ----
      if type(kwargs) != type(dict()):
          raise TypeError("3rd arg must be a dict")
+     global _main
+     _main = False
      try:
          function(*args, **kwargs)
***************
*** 51,56 ****
      except:
          _traceback.print_exc()
      if _interrupt:
-         global _interrupt
          _interrupt = False
          raise KeyboardInterrupt
--- 53,59 ----
      except:
          _traceback.print_exc()
+     _main = True
+     global _interrupt
      if _interrupt:
          _interrupt = False
          raise KeyboardInterrupt
***************
*** 123,132 ****
          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
--- 126,140 ----
          return self.locked_status
  
! # Used to signal that interrupt_main was called in a "thread"
  _interrupt = False
+ # True when not executing in a "thread"
+ _main = True
  
  def interrupt_main():
      """Set _interrupt flag to True to have start_new_thread raise
      KeyboardInterrupt upon exiting."""
!     if _main:
!         raise KeyboardInterrupt
!     else:
!         global _interrupt
!         _interrupt = True