This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kristjan.jonsson
Recipients Sebastian.Noack, asvetlov, jyasskin, kristjan.jonsson, mklauber, pitrou, sbt
Date 2012-10-01.09:41:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Personally, I would prefer to make the shared and exclusive locks
> attributes of the same object, so one could do
>    with selock.shared:
>       ...
>    with selock.exclusive:
>       ...
> Please note, the "same object" could simply be a namedtuple instance.
With this, you are stuck with employing a context manager model only.  You loose the flexibility to do explicit acquire_read() or acquire_write().
My latest patch has methods shared_lock(), exclusive_lock() that return proxy lock objects that can be used like context managers like you describe, but you still have the flexibility of using the lock manually.

As for the bikeshedding, let's look at the list of concrete implementations out there:
Windows: SRW locks (slim reader writer)
Pthreads: rwlock_t (reader/writer)
Java: ReadWriteLock,

Am I missing anything?
Don't see why we need to adopt a completly different name or idiom to what people are used to.  Also, note that the java version is quite similar to Richard's proposal.
Date User Action Args
2012-10-01 09:41:16kristjan.jonssonsetrecipients: + kristjan.jonsson, pitrou, jyasskin, asvetlov, sbt, mklauber, Sebastian.Noack
2012-10-01 09:41:16kristjan.jonssonsetmessageid: <>
2012-10-01 09:41:16kristjan.jonssonlinkissue8800 messages
2012-10-01 09:41:15kristjan.jonssoncreate