When I deal with this simple integral, I found there are several methods. Now I share one of them.
Letting $x\mapsto \pi-x $ yields $$I=\int_{0}^{\pi} \frac{d \theta}{a+b \cos \theta}=\int_{0}^{\pi} \frac{d \theta}{a-b \cos \theta}$$ Adding two versions together yields $$ \begin{aligned} 2 I &=2 a \int_{0}^{\pi} \frac{d \theta}{a^{2}-b^{2} \cos ^{2} \theta} \\ &=4 a\int_0^{\frac{\pi}{2}} \frac{\sec ^{2} \theta}{a^{2} \sec ^{2} \theta-b^{2}} d \theta \quad \textrm{( By symmetry )}\\ &=4 a{\int_{0}^{\infty}} \frac{d t}{\left(a^{2}-b^{2}\right)+a^{2} t^{2}} \\ &=\frac{4}{\sqrt{a^{2}-b^{2}}}\left[\tan^{-1} \left(\frac{at}{\sqrt{a^{2}-b^{2}}}\right)\right]_{0}^{\infty} \\ &=\frac{2 \pi}{\sqrt{a^{2}-b^{2}}} \end{aligned} $$
We can now conclude that $$ \boxed{I=\frac{\pi}{\sqrt{a^{2}-b^{2}}}} $$
Are there any other methods to deal with the integral?