python multithreading semaphore