[Python] Almost empty script running twice [closed]

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

  1. Stack

    Stack Membro Participativo

    Python version 3.12.6 installed with homebrew on MacOS 15.3.1 (24D70) with an Apple M2 Max.

    File called foo.py

    from multiprocessing import Process

    print("Foo")

    def start():
    print("Bar")

    if __name__ == '__main__':
    p = Process(target=start)
    p.start()


    When running python3 foo.py

    Foo
    Foo
    Bar
    Bar


    I can grasp why there could be two Foo but why are there two Bar?

    Continue reading...

Compartilhe esta Página