Python Forum

Full Version: How to intercept python method calls?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I have a python program running as process. I am looking for mechanism to intercept selected function in python program which is already running (at run time) and get the control of the function.
Example:
def function1():
   try{
       .....
   } catch(exception ex) {
       .....
   }
Let's say, the above specified function is part of the python program running. I am looking for a mechanism using which I can instruct python to return the exception each time the function1 is called (irrespective of try condition).
I have come across parasite project which allows us to connect to running process and execute a code but, doesn't seem to help in controlling behavior of a method in the target process.

Thanks,
Dinesh