Re: How to go about. On read/write locks

2009-04-08 Thread Piet van Oostrum
> Carl Banks (CB) wrote: >CB> On Apr 6, 2:23 pm, "Diez B. Roggisch" wrote: >>> > This is a classical synchronization problem with a classical solution: >>> > You treat the readers as a group, and the writers individually. So you >>> > have a write lock that each writer has to acquire and rel

Re: How to go about. On read/write locks

2009-04-07 Thread Piet van Oostrum
> "Diez B. Roggisch" (DBR) wrote: >>> This is a classical synchronization problem with a classical solution: >>> You treat the readers as a group, and the writers individually. So you >>> have a write lock that each writer has to acquire and release, but it is >>> acquired only by the first r

Re: How to go about. On read/write locks

2009-04-06 Thread Carl Banks
On Apr 6, 2:23 pm, "Diez B. Roggisch" wrote: > > This is a classical synchronization problem with a classical solution: > > You treat the readers as a group, and the writers individually. So you > > have a write lock that each writer has to acquire and release, but it is > > acquired only by the f

Re: How to go about. On read/write locks

2009-04-06 Thread Carl Banks
On Apr 6, 3:30 am, "Emanuele D'Arrigo" wrote: > Python's approach with the GIL is both reasonable and disappointing. > Reasonable because I understand how it can make things easier for its > internals. Disappointing because it means that standard python cannot > take advantage of the parallelism t

Re: How to go about. On read/write locks

2009-04-06 Thread Diez B. Roggisch
Python's approach with the GIL is both reasonable and disappointing. Reasonable because I understand how it can make things easier for its internals. Disappointing because it means that standard python cannot take advantage of the parallelism that can more and more often be afforded by today's com

Re: How to go about. On read/write locks

2009-04-06 Thread Diez B. Roggisch
This is a classical synchronization problem with a classical solution: You treat the readers as a group, and the writers individually. So you have a write lock that each writer has to acquire and release, but it is acquired only by the first reader and released by the last one. Therefore you need

Re: How to go about. On read/write locks

2009-04-06 Thread Emanuele D'Arrigo
On Apr 6, 12:44 pm, Piet van Oostrum wrote: > 3. See also http://code.activestate.com/recipes/465156/ Thank you for the useful suggestions Piet. In particular I just had a look at the SharedLock class provided through the link above and it seems to fit the bill quite nicely. I'll give it a go! T

Re: How to go about. On read/write locks

2009-04-06 Thread Piet van Oostrum
> "Emanuele D'Arrigo" (ED) wrote: >ED> Hi everybody, >ED> I'm having a threading-related design issue and I suspect it has a >ED> name that I just don't know. Here's a description. >ED> Let's assume a resource (i.e. a dictionary) that needs to be accessed >ED> by multiple threads. A simple

Re: How to go about. On read/write locks

2009-04-06 Thread Emanuele D'Arrigo
On Apr 6, 7:49 am, "Diez B. Roggisch" wrote: > The CPython-specific answer is that the GIL takes care of that for you > right now anyway. So unless you plan for a distant future where some > kind of swallows fly around that don't have a GIL, you are safe to > simply read and write in threads witho

Re: How to go about. On read/write locks

2009-04-05 Thread Diez B. Roggisch
Emanuele D'Arrigo schrieb: Hi everybody, I'm having a threading-related design issue and I suspect it has a name that I just don't know. Here's a description. Let's assume a resource (i.e. a dictionary) that needs to be accessed by multiple threads. A simple lock will do the job but in some ci