Python Forum
How to intercept python method calls? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to intercept python method calls? (/thread-19795.html)



How to intercept python method calls? - DineshBhat - Jul-15-2019

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