How to call a python function inside of a command line while application is running?

Viewed 31

How do i call a function inside my application from the command line while the application is already running.?

I am trying to make a .bat file that opens gui of my application, even though the application is running in the background.

1 Answers

The shell script cannot communicate directly with a running process.

The simplest and “dirty” way is to make your script polling for some file in a predefined path and execute your code if you create the file.

from os.path import exists

while True:

print("Waiting for the creation of the file.")
time.sleep(5)

if exists("path_to_file"):
    run_your_code
Related