?
Say "Hi" to the person who is passing, then turn back to the first person. Don't start a conversation with the new person. If you need to talk to them, you can say, "Can you wait just a minute? I need to talk to you." Then finish your conversation with the first person.
?
Acknowledge the person walking past and then apologize to the person your speaking with for the diversion.