[Python] How to catch the duration and return value of many python parallel sub-process

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I need to write some code in python that launches 8 processes in parallel and that, for each process, is able to report their return value and their duration in microseconds.

    Unfortunately I don't know how to do it.

    I imagined launching the processes with:

    p = subprocess.Popen([f"{my_process}"], shell=True, universal_newlines = True, stderr=subprocess.STDOUT, stdout=DEVNULL)


    and waiting for their termination with:

    p.wait()


    measuring their start and stop time with:

    datetime.now()


    but what I don't know how to do is capture the durations of each process in parallel, also taking the return value of each.

    Do you think this task is too difficult for python? I guess not, but I can't get out of it!

    Can someone help me please?

    Thanks

    Continue reading...

Compartilhe esta Página