When the public security is manifestly endangered by any such assembly and no Executive Magistrate can be communicated with, any commissioned or gazette officer of the armed forces may disperse such assembly with the help of the armed forces under his command, and may arrest and confine any persons forming part of it, in order to disperse such assembly or that they may be punished according to law, but if, while he is acting under this section, it becomes practicable for him to communicate with an Executive Magistrate, he shall do so, and shall thenceforward obey the instructions of the Magistrate, as to whether he shall or shall not continue such action.