single thread decrement a semaphore object more than once?
Christian Heimes
lists at cheimes.de
Tue Feb 24 23:57:43 EST 2009
birdsong wrote:
> I searched but didn't see this already discussed, sorry if I didn't
> search hard enough.
>
> Can I decrement a semaphore's counter within the same thread more than
> once? I'd like to set hard and soft limits in a server I'm writing.
> The server upon initialization would create a semaphore:
>
> threading.Semaphore(100)
Yes, you are not restricted to multiple threads. A semaphore ensures
that the counter is thread safe. It doesn't force you to use threads.
Christian
More information about the Python-list
mailing list