Python Language Using Parent and Children scripts to execute code in parallel


Example

child.py

import time

def main():
    print "starting work"
    time.sleep(1)
    print "work work work work work"
    time.sleep(1)
    print "done working"

if __name__ == '__main__':
    main()

parent.py

import os

def main():
    for i in range(5):
        os.system("python child.py &")

if __name__ == '__main__':
    main()

This is useful for parallel, independent HTTP request/response tasks or Database select/inserts. Command line arguments can be given to the child.py script as well. Synchronization between scripts can be achieved by all scripts regularly checking a separate server (like a Redis instance).