Not able to establish connection while extracting gps data

I want to connect pixhawk which is running ardupilot to my topside computer. I also need to extract the gps information from the pixhawk at the same time. The way i am doing this is by connecting the pixhawk to topside computer using mavproxy. I wrote a separate python program to extract gps information using mavutil program and sent to the topside computer using udp socket.

The problem i am facing is that i can’t do this both simultaneously. If i starts mavproxy, i cannot run the gps program(i think the problem is with accessing same port for two uses). so i embedded the gps code with the mavproxy program. Now i get the gps data correctly but mavproxy takes too much time to connect the QGC.
Is there a way to solve this problem?