I'm calling a 3rd party python library from within my code, which in response to an exceptional condition simply exits rather than raiseing an exception. I think the exit itself is not coming from within python itself but from a linked C file. using strace on linux definitely reveals that it is calling exit.
Unfortunately, this causes my entire program to exit. What I want is to be able to capture this "exit" event and raise an exception, then have my handling code make some changes to the parameters and call again. I'm looking at ways to capture an exit event, and so far I've seen atexit, which doesn't actually seem to allow you to continue execution, and also I could isolate the call in a subprocess to firewall myself from the exit event. This seems like too inelegant of a solution to me, so I'm wondering if anyone else can weigh in on what can be done here.
I haven't tried anything concrete at this point, I'm just looking for possible solutions to this problem.