'run parallel commands in subprocess and get their names?

I have a python script that's part of a flask project that performs a time consuming task.I had written it in such a way that all the commands (about 6 of them) will be executed in parallel and their return codes are collected as well .

However while printing out the message of which command had failed , which ones had succeeded, i seem to have hit a block

is there a way that i could get the cmd name (just a part of the command) to be printedout ? so the users know which commands failed and which succeeded ?

## Start of Process ##

print("\nBeginning Log fetch")
print("="*27)
start_process=time.time()

cmd_list=["cmd_name#1,"cmd_name#2","cmd_name#3","cmd_name#4"
,"cmd_name#5","cmd_name#6"]

procs=[subprocess.Popen(i,shell=True,stdout=subprocess.PIPE) for i in cmd_list]

for p in procs:
    p.wait()
    print(p.communicate())
    if p.returncode !=0:
        print ("\n\nTask Failed!! :\n")
    else:
        print ("\nTask Succeeded!\n")
        fileproc()

end_process=time.time()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source