The court before which any person is convicted of a crime, which by the judgment of such court is punished otherwise than by imprisonment for more than one year, may require such person to enter into an undertaking to keep the peace, as provided in section 4005(a) of this title, for a period not exceeding one year and in default thereof may commit him until the undertaking be given or the period expired.