Use python timers instead of thread + sleep
(cherry picked from commit bcdeb79bef6188705dab93f46948fc6d514e24dd)