Manage timeouts without using signal.alarm