Using Parent and Children scripts to execute code in parallel
suggest change# name: parent.py
import os
def main():
for i in range(5):
os.system("python child.py &") # Unix shell: & runs the child in the background
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).
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents