single thread decrement a semaphore object more than once?

birdsong david.birdsong at gmail.com
Wed Feb 25 02:52:23 EST 2009


On Feb 24, 8:57 pm, Christian Heimes <li... at cheimes.de> wrote:
> 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

ahh good. there will be multiple threads accessing, but yes i follow
now.  i guess this would have been pretty easy to test in the shell.

muchas gracias.



More information about the Python-list mailing list