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.