0

How to run 2 or more scripts, starting from 1 single script?

As far as I know, scripts (e.g. Python) always run a line at a time, and thus something like: exec(codeA) exec(codeB) # These 2 codes are big can takes about an hour to run each of them. will first run the codeA. codeB won't start until codeA has finished completely. That's fine. But I find out my PC's CPU usage is just around 30% during code running. Then, I wonder, maybe, if there is a way to run codeA and codeB simultaneously with using about 60% CPU, and tremendously speeds up the calculation. I have found something like this in shell script: https://stackoverflow.com/questions/12907721/run-three-shell-script-simultaneously Thus, I am curious of, if any other language has this kind of features? and how to do? (especially in Python) I expect something looks like: exec(codeA) and exec(codeB) # of course this is not working Any suggestions are welcome! :)

15th Jun 2018, 6:49 PM
李立威
2 Respostas
+ 1
As far as I'm aware, Python doesn't have functionality for asynchronous scripts. Delve into the python docs to confirm. I've started using Node.js with my vanilla JS and extensively using asynchronous file handling: to increase performance and speed. LUA has the 'with' statement, which executes a function in the background. ... End
15th Jun 2018, 7:08 PM
ghostwalker13
ghostwalker13 - avatar