Hey I am a beginner in development and I need your inputs please.
I have an ops.py which monitors the exit status of main.py:
Below is the ops.py:
import subprocess
import sys
def main():
try:
process = subprocess.Popen(['python', 'main.py'])
process.wait()
exit_status = process.returncode
print("Exit status of the main script:", exit_status)
except Exception as e:
print("Error:", e)
if name == "main":
main()
If I run the ops.py independently I get the output, but I need to execute this script only when the main.py is executed, inorder to track the exit status of main.py only when it is being executed.
I tried importing the ops.py in main.py, (doesn’t work) I used subprocess.run([‘python’, ‘ops.py’]) (doesn’t work)
I am doing this experiment to know if the main.py failed of passes during execution.
Open to Suggestions
python_craze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.