Python: Run multiple scripts simultaneously from the same translator

I have a python script that runs 4-5 python scripts again . For performance reasons, I want to use the same interpreter to execute all scripts.

How can I deal with this problem?

+1
source share
4 answers

The obvious solution (which may require a little tweaking) is to simply call the main function of each script from the script wizard. For example, if script1.py contains:

#!/usr/bin/python
def main():
  // Do something
if __name__ == "__main__":
   main()

enter master.py

#!/usr/bin/python
import script1
def main():
  script1.main()

if __name__ == "__main__":
  main()

You can continue this template for as many scripts as possible.

+8
source

, execfile Python 2.x.

Python 3 , .

+3

sys.executable. subprocess.Popen "" .

0

, , "" script :

import os
os.system('python script1.py')
os.system('python script2.py')
os.system('python script3.py')
os.system('python script4.py')
0

All Articles