How smart are Semaphore Objects?

Matthew D. Wood woodm at equire.com
Tue Oct 30 01:53:29 EST 2001


I firmly believe that when coding a function, object, program or
whatever, one should assume that every other function, ... is either
stupid or out to get you.  With this mind-set, I'm curious as to how
(idiot or mean-person) proof semaphore objects are.

Threading.Semaphore.

If a class can't acquire a semaphore, or doesn't bother, can it
release it, despite not owning it?

It's almost a security thing.  I want in, and so, I will release the
semaphore, repeatedly if necessary, until I get in.


Is the semaphore able to avoid this kind of thing?  Or do you just
have to rely on the fact that people generally don't try to release a
semaphore that they haven't acquired?


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.  

Thanks for helping.  I really appreciate the time and effort.



More information about the Python-list mailing list