Years ago I use to have to replace the thermal couple on this heater we had.I had to replace it about every four or five years.
It was pretty easy to replace.
I can not remember if the pilot would stay lit for a bit at all or not.
If it flickers then it may have debris in the tube. Turn off the pilot light gas valve (or the main gas valve for the furnace) and then remove the pilot light gas tube. Blow some compressed air thru it and see if any blockage comes out. Reconnect and see it that helps.
If the pilot light is strong then you may need a chimney cap to keep down drafts from blowing out the pilot light.