How smart are Semaphore Objects?
Matthew D. Wood
woodm at equire.com
Tue Oct 30 15:38:50 CET 2001
Ype Kingma <ykingma at accessforall.nl> wrote in message
> A Semaphore can be released from an other thread.
> You might prefer to use RLock. Releasing it is documented ao. by:
The reason I wanted to use a semaphore, instead of a (lock or Rlock)
was the counting ability. I'm trying to limit my number of threads to
say 50. You can't do that with an Rlock, right?
Hmmmm. Maybe a condition with an Rlock... I will have to look.
> It can be better for performance to release a Semaphore from another thread.
> I would consider this as a candidate for style improvement, though.
I don't understand. Why would it be better for a non-owning thread to
release a Semaphore?
> > This may seem a bit paranoid, but in big groups, paranoid is so
> > important. My code may be a bit large, but it's never the part that
> > crashes because of a divide by 0 or a file didn't open because it
> > never existed.
> > Maybe there is an exception the Semaphore raises? I don't know.
> When you are paranoid enough test RLock. You'll like it.
Like I said, RLock seems like a 1 or 0 thing. I need a less than
> > Thanks for helping. I really appreciate the time and effort.
> My pleasure,
Again, thank you.
More information about the Python-list