This is all subjective.........If a bad guy had a gun, I would not pepper spray him for fear of being shot. That is unless I truly believed his was going to shoot me (because he shot someone else or something like that). If he had a knife, I would pepper spray him unless I was restricted in my movement (meaning I could not get away). Know that during most knife fights, you will be slashed or stabbed.
This of course applies to me being off duty. On duty, it's on....
David