0

I'm trying to run multiple scripts to maintain the running speed.

I'm using two scripts that need each other to work, so I want another Python script like setup.py to run them:

import os
os.system('python script1.py && python script2.py')

But that doesn't work at the same time.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Ali
  • 615
  • 10
  • 16
  • Does this answer your question? [Python: execute cat subprocess in parallel](https://stackoverflow.com/questions/23611396/python-execute-cat-subprocess-in-parallel) – nnnmmm Apr 15 '20 at 13:21
  • Your use case isn't very well defined. If `script2.py` depends on `script1.py`, the you cannot run them in parallel. (Or, at least not completely.) Is this the case or do you want to run both scripts together multiple times in parallel? – JohanL Apr 19 '20 at 04:57

1 Answers1

2

maybe you can use multithreading : Python - Multithreading

You will be able to run different python scripts in different threads.

That will allow you to execute them in the same time.

If your script doesnt require a lot of layers of data to process, then you can keep using your processor.

Otherwise you can use your GPU. For example cuda for NVIDIA GPU : See cuda here

Julien J
  • 2,826
  • 2
  • 25
  • 28