2

I am trying to run multiple functions at the same time. To save time modifying file by file, I converted the files into functions and imported them from another .py, but when I run it they execute in order, and they start when the previous one finishes

Is there a way to run them all at once from the same python (.py) script/file?

from DosAAMismoDTotal import DosAAMismoDTotal
from DosABAnteriorDTotal import DosABAnteriorDTotal
from DosACSiguienteDTotal import DosACSiguienteDTotal
from DosBAMismoDP import DosBAMismoDP
from DosBBMismoDU import DosBBMismoDU
from DosBCAnteriorD import DosBCAnteriorD
from DosBDSiguienteD import DosBDSiguienteD


fisrt = 'xpath1'
second = 'xpath2'
one = 'xpath3'
two = 'xpath4'
three = 'xpath5'

functionone(fisrt, second, one)
functiontwo(fisrt, second, two)
functiononethree(fisrt, second, three)
functiononefour(fisrt, second, one)
functiononefive(fisrt, second, one)
functiononesix(fisrt, second, two)
functiononeseven(fisrt, second, three)
tpvasconcelos
  • 671
  • 7
  • 19
Dandal
  • 166
  • 1
  • 11
  • 1
    You can use multi threading (on 1 core) or multiprocessing (multiple cores). Example [threading](https://stackoverflow.com/questions/2846653/how-can-i-use-threading-in-python), and an example for [multiprocessing](https://stackoverflow.com/questions/44660676/python-using-multiprocessing). Or check the official docs [here](https://docs.python.org/3/library/threading.html?highlight=threading#module-threading) (currentyl at threading, but you can also search for multiprocessing. – Thymen Dec 16 '20 at 22:26
  • I only managed to execute the functions one after the other with "threading.Thread (target =" and "Process (target =". So I chose to create a .py and import the variables from it, for each function in separate files: ```from defvariable import (fisrt, second, one, two, three)``` – Dandal Dec 17 '20 at 00:36

0 Answers0