Couldn't you do almost the exact same thing using pdb, without all the C API / register stuff?
Maybe I misunderstood the post, but it sounds like you're just stopping right before the request returns, reloading the module, generating a new response, and allowing execution to continue.
Why is GDB required for any of this?