That is not the exception. Here the verb after the preposition - from - is have. And it's no exception to write having there. The verb have can take a to-infinitive clause to mean obligation, for example, I have to do it. And so it's grammatical to write keep me from having to mingle.
A few similar examples -
I could walk no more than a few feet without having to pause to net an unfamiliar species.
It will save you from having to pay your full deductible two-years in a row.
They're really well-adjusted around this business and understanding the nature of having to take a battering.