[Python-Dev] Proposed addition to threading module (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Tue Apr 25 01:35:46 CEST 2006
- Previous message: [Python-Dev] Proposed addition to threading module - released
- Next message: [Python-Dev] Proposed addition to threading module - released
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tim Peters wrote:
Does
with cv: work to replace the outer (== only) acquire/try/finally/release dance?
Indeed it does - although implemented in a somewhat convoluted way: A lock is a context (or is that "context manager"), i.e. it implements
def context(self): return self enter=acquire def exit(self,*args): return self.release() #roughly
A _Condition has a lock, so it could become the context (manager?) through
def context(self): return self.lock
However, instead of doing that, it does
def context(self): return self
roughly: enter is actually set in init to self.lock.acquire
def enter(self): return self.acquire() def exit(self): return self.release
Looks somewhat redundant to me, but correct.
Regards, Martin
- Previous message: [Python-Dev] Proposed addition to threading module - released
- Next message: [Python-Dev] Proposed addition to threading module - released
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]