Praise be to Allah.
With regard to the fast, that does not invalidate it.
With regard to purification and prayer:
This pus that comes out of the urethra is najis (impure). If it comes out occasionally, but usually it does not come out, then it is obligatory to purify oneself of it every time it comes out, and to wash off whatever of it has gotten onto the body or clothes. It invalidates wudoo, and if comes out during the prayer, it renders it invalid. So in that case he should stop praying, go and purify himself and do wudoo’, and start the prayer all over again.
But if it comes out all the time, then it comes under the same ruling as urinary incontinence. In this case, he should clean himself (instinja’), purify anything it got onto, wrap something over it so that it will not get onto his garment and the impurity will not spread further, then he should do wudoo’ at the time of each prayer, and it will not matter if it comes out after that.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) was asked about a man who had a constant discharge of pus from his penis: is his prayer valid when this is coming out?
It is not permissible to give up praying; rather he should pray according to what he is able to do. If the impurity does not stop long enough for him to do wudoo’ and pray, then he should pray according to his situation, after doing wudoo’, even if the impurity comes out whilst he is praying. But he should put something over it so as to prevent the impurity spreading further. And Allah knows best.
End quote from Majmoo‘ al-Fataawa (21/219)
Please see also the answer to question no. 20474
And Allah knows best.