[Python-checkins] python/dist/src/Lib threading.py,1.19.12.2,1.19.12.3

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Sun, 02 Feb 2003 11:24:41 -0800


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

Modified Files:
      Tag: release22-maint
	threading.py 
Log Message:
backport:

revision 1.29
date: 2002/11/21 21:08:39;  author: gvanrossum;  state: Exp;  lines: +14 -8
The _Event class should be more careful with releasing its lock when
interrupted.  A try/finally will do nicely.  Maybe other classes need
this too, but since they manipulate more state it's less clear that
that is always the right thing, and I'm in a hurry.



Index: threading.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v
retrieving revision 1.19.12.2
retrieving revision 1.19.12.3
diff -C2 -d -r1.19.12.2 -r1.19.12.3
*** threading.py	19 Feb 2002 03:02:33 -0000	1.19.12.2
--- threading.py	2 Feb 2003 19:24:38 -0000	1.19.12.3
***************
*** 317,334 ****
      def set(self):
          self.__cond.acquire()
!         self.__flag = 1
!         self.__cond.notifyAll()
!         self.__cond.release()
  
      def clear(self):
          self.__cond.acquire()
!         self.__flag = 0
!         self.__cond.release()
  
      def wait(self, timeout=None):
          self.__cond.acquire()
!         if not self.__flag:
!             self.__cond.wait(timeout)
!         self.__cond.release()
  
  # Helper to generate new thread names
--- 317,340 ----
      def set(self):
          self.__cond.acquire()
!         try:
!             self.__flag = 1
!             self.__cond.notifyAll()
!         finally:
!             self.__cond.release()
  
      def clear(self):
          self.__cond.acquire()
!         try:
!             self.__flag = 0
!         finally:
!             self.__cond.release()
  
      def wait(self, timeout=None):
          self.__cond.acquire()
!         try:
!             if not self.__flag:
!                 self.__cond.wait(timeout)
!         finally:
!             self.__cond.release()
  
  # Helper to generate new thread names