Is there a way I can write a python script that emulates the use of GNU Screen and Bash? I was originally trying to write a simple Bash script, but I suspect learning the multiprocessing
module will give me a little bit flexibility down the road, not to mention that python modules are very well documented.
So, I have seen in the tutorials and documentation the use of a single function run in parallel, but am a little bit lost on how to make to use this. Any reference would be extremely helpful.
Below is basically what I want:
If I have a bunch of experiments in different python files, then in Bash:
$python experiment1.py&
$python experiment2.py& ...
In Python, if I have a bunch of functions in the same script, the main emulates the above (? this is really just a guess and don't mean to offend people other than myself with my ignorance):
import multiprocessing as mp
def experiment1():
"""run collection of simulations and collect relevant statistics"""
....
def experiment2():
"""run different collection of simulations and collect relevant statistics"""
....
if __name__ == '__main__':
one = mp.process(target = experiment1)
two = mp.process(target = experiment2)
...
one.start()
two.start()
...
one.join()
two.join()
I am not sure how I would test this except maybe my activity monitor on OSX, which doesn't seem to tell me the distribution of the cores, so suggestions as to checking python-ically without runtime would be helpful. This last question might be too general, but thought I would throw it in. Thank you for your help!