1. Armin Rigo
  2. cpython-withatomic


Guido van Rossum  committed 269c62c

Implement MvL's improvement on __context__ in Condition;
this can just call __context__ on the underlying lock.
(The same change for Semaphore does *not* work!)

  • Participants
  • Parent commits 68a7c01
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Lib/threading.py

View file
  • Ignore whitespace
         self.__lock = lock
         # Export the lock's acquire() and release() methods
         self.acquire = lock.acquire
-        self.__enter__ = self.acquire
         self.release = lock.release
         # If the lock defines _release_save() and/or _acquire_restore(),
         # these override the default implementations (which just call
         self.__waiters = []
     def __context__(self):
-        return self
-    def __exit__(self, t, v, tb):
-        self.release()
+        return self.__lock.__context__()
     def __repr__(self):
         return "<Condition(%s, %d)>" % (self.__lock, len(self.__waiters))