[Tim] > Because Queue does use condvars now instead of plain locks, I wouldn't > approve of any gimmick purporting to hide the acquire/release's in > put() or get(): that those are visible is necessary to seeing that > the _condvar_ protocol is being followed ("must acquire() before > wait(); must be acquire()'ed during notify(); no path should leave the > condvar acquire()d 'for a long time' before a wait() or release()").
So you think that this would be obscure? A generic condition variable use could look like this: block locking(self.condvar): while not self.items: self.condvar.wait() self.process(self.items) self.items = [] instead of this: self.condvar.acquire() try: while not self.items: self.condvar.wait() self.process(self.items) self.items = [] finally: self.condvar.release() I find that the "block locking" version looks just fine; it makes the scope of the condition variable quite clear despite not having any explicit acquire() or release() calls (there are some abstracted away in the wait() call too!). -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com