A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-May/053248.html below:

[Python-Dev] PEP 340 -- concept clarification

[Python-Dev] PEP 340 -- concept clarification [Python-Dev] PEP 340 -- concept clarificationGuido van Rossum gvanrossum at gmail.com
Tue May 3 21:48:05 CEST 2005
[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/)
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4