In intense gymnastics training students will be required to do big conditioning skills. One of these happens to be a handstand pushup.
This is a rather dangerous skill and it requires a couple of years of learning exactly how to do a handstand first. Again, if you are doing anything with a handstand you need to make sure you hit that handstand prior to doing any skill afterwards.
When doing a handstand pushup you want to make sure you have a spot to start with. You always want to make sure that you are on a soft landing in case your arms collapse. You don't want to be too aggressive on dropping. You want to slowly come down and push back up, focusing not only on pushing but also keeping your body straight.
As in if you start wiggling, if your body is contorted and starts to twist or something, it's going to be a lot harder to push back up and eventually you're going to fall over. The key in doing this is good body positioning. Keep your body straight and then slowly come down and push back up.
There are a couple drills you can do. One would be a pike handstand on an elevated mat working on keeping your fingers and shoulders all up to your hips in a straight line. Your hips are over top of your head and doing pushups like that. This will take away weight of your lower body.
Also from that position you can lift one leg up to add a little bit more weight and do the pushups again. And then eventually you can end up getting spotted, someone holding you in a handstand and doing the pushups from there.