Whenever, by the provisions of this title, an officer is required to keep a person arrested on a warrant of attachment in custody, and to bring him before a court or judge, the inability, from illness or otherwise, of the person to attend, is a sufficient excuse for not bringing him up; and the officer must not confine a person arrested upon the warrant in a prison, or otherwise restrain him of personal liberty, except so far as may be necessary to secure his personal attendance.