Good point, I hadn't thought of that.


On Wed, Apr 10, 2013 at 4:23 PM, Bernie Hackett <notifications@github.com>wrote:

> In pymongo/thread_util.py:
>
> > +class DummySemaphore(object):
> > +    def __init__(self, value=None):
> > +        pass
> > +
> > +    def acquire(self, blocking=True, timeout=None):
> > +        return True
> > +
> > +    def release(self):
> > +        pass
> > +
> > +
> > +class ExceededMaxWaiters(Exception):
> > +    pass
> > +
> > +
> > +class MaxWaitersBoundedSemaphoreThread(BoundedSemaphore):
>
> This seems overly complicated to me. You can achieve the same thing using
> two semaphores, one that is essentially just a counter (the outer
> semaphore) and one that can be waited on (the inner semaphore). If a thread
> cant acquire the outer semaphore an exception is immediately raised. If it
> can acquire the outer semaphore it can either immediately get a socket, or
> wait on the inner semaphore. The advantage is we don't have to have two
> more semaphore implementations to maintain ourselves, only the one for
> CPython. The code may be *slightly* more complex but not needlessly so.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/mongodb/mongo-python-driver/pull/163/files#r3744820>
> .
>



-- 
Justin Patrin
Developer Extraordinaire