I know this is not the advice you want to hear, but I wouldn't be giving good advice if I gave advice in which I didn't personally believe.... Unfortunately, from the way you are describing your situation, it seems to me like keeping your distance, or even breaking contact completely, is your best bet.
It would be entirely different if you could set aside your feelings for her and accept being just friends, since nothing else is currently possible. If you could honestly, legitimately do that, then I'd say stay friends with her. Because, Hell, you never do know. In time, maybe she'd become single, maybe you'd still be single too, and maybe that would be the opportunity for you to ask her out. Or, maybe you'd remain friends and eventually you'd find somebody else, but at least you'd still have her as a friend.
The thing is, it sounds like remaining her friend is not only keeping your desire for more alive.... it is also hurting you. Unfortunately, it sounds to me like you don't really want to just be her friend, you want to be more. Right now, though, that isn't possible because she has somebody. You don't know if that will last or if it will end tomorrow. You can't wait around forever, putting your life on hold, for something that may never happen. What if you waited around and months or years down the road, they wind up getting engaged?
I know this is so much easier said than done, but if being close to her is hurting too much because you only want to be even closer, than it may be for your own best to just keep your distance. Again, she's done nothing wrong, so it isn't like you should be rude to her or anything. But, you don't deserve the hurt that this situation brings you, nor do you deserve to be stuck in limbo. You could miss the person with whom you are really meant to be because you are stuck on one you cannot have.
Good luck to you.