ENH: add timeout using threading