They are better than nothing. Gas pistols give you a little bit of range, and can provide an opportunity to escape. That said, they are an inferior weapon. They rely on pain to induce compliance or incapacitate someone. That does not always work. Some people's bodies do not react to OC/CS with the normal severity. Others may be so drugged up that the pain does not bother them.
I would not view them as a method to stop an attack, but as a tool to buy you a few more seconds to either escape or deploy a better method of defense (if cornered).