Sometimes python's threading interfaces are quite frustrating. What i would like today is: the ability to wait for an unspecified number of threads to finish. Ideally this would work like this:
- each thread calls semaphore.release() at the start, and semaphore.acquire() at finish.
- the waiter blocks until the semaphore count is 0.
Unfortunately, that's not possible. Python's semaphore objects are opaque, so you can't tell the count, and offer no method to wait for 0.
Another contender would be threading.Barrier(). Unfortunately it requires you to know the exact number of threads when you initialize it, with no option to change that number later.