Home > Software design >  How to run two python scripts, simultaneously?
How to run two python scripts, simultaneously?

Time:10-30

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 ?

CodePudding user response:

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.

CodePudding user response:

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

  • Related