[Python] In Python multiprocessing, why is child process name __mp_main__? Is there a way to...

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    #!/usr/bin/env python3

    import multiprocessing as mp


    def child_process():
    print('Hi! My name is', __name__)


    print('Hi! My name is', __name__)
    if __name__ == '__main__':
    mp.Process(target=child_process).start()



    The above code output it as below: [​IMG]

    I am confused about

    1. Why is the child process name __mp_main__?
    2. Why is it printed twice?

    Continue reading...

Compartilhe esta Página