I'm looking for a thread-safe implementation of a Semaphore I can use in Python. The standard libraries asyncio.Semaphore isn't thread-safe. The standard libraries threading.Semaphore doesn't have awaitable interface. I am using sanic which has multiple threads (workers) but also an asynchronous loop on each thread. I want to be able to yield execution back to the event loop on each of the workers whenever it encounters a blocked semaphore, while it waits. UPDATE: I meant to say process here, not threads. So these should be that Sanic splits across processes, and multiprocessing.Semaphore. I believe the answer given is still relevant to where I can apply a similar solution. Continue reading...