I want to call a method in running python script from another script.
For eg:
script1.py is continuously running. In this script there are methods.
From another script2.py i want to call method of script1.py
I want to call a method in running python script from another script.
For eg:
script1.py is continuously running. In this script there are methods.
From another script2.py i want to call method of script1.py
What you want is the multiprocessing module and a Manager object. Create a Manager object in script1.py, register the methods you want to call, and then start the server.
The module documentation has a good example of how to do all this.
https://docs.python.org/3/library/multiprocessing.html#multiprocessing-managers
Specific examples on how to use a remote manager can be found here.
You can import sript1.py and use function from it, because the script1.py is cached by interpreter. If I understand the question correctly.
import script1, you don't prevent to the running script1.py.