[Python-Dev] I'd like list.pop to accept an optional second

M.-A. Lemburg mal@lemburg.com
Sat, 24 Jul 1999 10:38:59 +0200


Tim Peters wrote:
> 
> > ...
> > Hmm, so maybe we're not after lists after all: maybe what
> > we need is access to the global interpreter lock in Python,
> > so that we can write:
> >
> > sys.lock.acquire()
> > if list:
> >         obj = list.pop()
> > else:
> >         obj = default
> > sys.lock.release()
> 
> The thread attempting the sys.lock.acquire() necessarily already owns the
> global lock, so the attempt to acquire it is a guaranteed deadlock --
> arguably not helpful <wink>.

True, sys.lock.acquire() would have to set a flag *not* to release
the lock until the next call to sys.lock.release(), which then
clears this flag again. Sort of a lock for the unlocking the lock ;-)

Could this work, or am I having a mind twister somewhere in
there again ?

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                   160 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/