-2

I have two python scripts, both of whom i need to start at exactly the same time

This is because i am trying to measure performance metrics of both the scripts and it is a compulsory requirement of the task at hand that both of them should have started their execution at the same time

Is there a trivial way to do this?

Preferably through a third python script, which executes them both at the same time ?

Muhammad Yasir
  • 417
  • 5
  • 12
  • 1
    Does this answer your question? [Run multiple python scripts concurrently](https://stackoverflow.com/questions/28549641/run-multiple-python-scripts-concurrently) – Gino Mempin Oct 29 '22 at 10:12
  • 1
    Does this answer your question? [How to run two python scripts simultaneously from a master script](https://stackoverflow.com/q/50980648/2745495) – Gino Mempin Oct 29 '22 at 10:13
  • Does this answer your question? [Run two python files at the same time](https://stackoverflow.com/q/49875889/2745495) – Gino Mempin Oct 29 '22 at 10:17
  • How long do the scripts run, and how small must the start time difference be? – Kelly Bundy Oct 29 '22 at 11:48
  • @KellyBundy , start time difference must be as low as possible, scripts run for around 6 or 7 to 10 minutes max – Muhammad Yasir Oct 29 '22 at 12:42

2 Answers2

0

It depends on what precision you mean with "exactly the same time".

If that means "within a microsecond", then it is probably not possible.

But it I write a script like this (assuming a POSIX operating system):

python a.py >/dev/null &
python b.py >/dev/null &

And run that with /usr/bin/time sh together.sh, the output is:

    0.00 real         0.00 user         0.00 sys

So that means that both python instances have started in less than 0.01 seconds.

Roland Smith
  • 42,427
  • 3
  • 64
  • 94
-1

I think you mean you want to open two python files at the same time? Just CTRL click them so that they are both selected and then press ENTER or right click --> open hope that helps

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 02 '22 at 04:48