changed Lock() to Semaphore(1) to avoid problems
(Python wakes up all waiting threads when Lock is released and not only one thread)