Make a synchronous function have a timeout