can I take stool softener while having contractions?

Can I take stool softener while having intense contractions? I have urge to poop and rectal pressure but I am in so much pain. And how long does it take til it works ??