Switched from using threading.condition to threading.lock for better control and clarity.