'How do I run Parent and Child Process concurrently

I have two files. One file shows a part of the image while the other one displays the entire image and a rectangle patch shows the active part of the image being displayed in the other file. I want to run these two files concurrently but the issue is that the other file opens only after the first file is closed. I have tried the following things:

  1. os.system("python E:/FYP/software/code/slide_map1.py &")
  2. subprocess.call([sys.executable, "E:\FYP\software\code\slide_map1.py", "&"])
  3. subprocess.Popen([sys.executable, "E:\FYP\software\code\slide_map1.py", "&"])
  4. subprocess.call(["python", "E:\FYP\software\code\slide_map1.py"]) and other similar techniques. None of the above-mentioned things have given the desired result. The second file opens only after the first file is closed. I would love to know if there is any other technique that solves my question.

Result:

enter image description here



Solution 1:[1]

Running the same scripts on threads or on multiple CPU cores using the multiprocessing module can be two possible ways of running the two files together.

Also, you might want to look into concurrency in python, to get a more indepth understanding of the same to fit it in your code perfectly.

For a quick lookup for future readers here is a list of possible and most commonly used ways -:

NOTE: The ways listed above are not all the possible ways of achieving concurrency, for all possible ways a better resource will be the official python documentation for the same.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1