Skip to content

Stub binary doesn't support sys.executable spawn/multiprocessing #20

@freakboy3742

Description

@freakboy3742

Describe the bug

The stub binary used to start an app is an effective replacement for the python binary; however, it isn't a perfect replacements. multiprocessing in spawn mode will try to invoke sys.executable to spawn a child; it's also common to use subprocess or os.spawn to try and start sys.exectuable to run other Python code as a subprocess. However, the stub binary doesn't support this kind of execution.

Steps to reproduce

  1. Generate a stub macOS app
  2. Add a call to call multiprocessing.Process() and start it with .start()

The subprocess will call the parent process entry point, and fail.

Expected behavior

The function targeted by Process() should be invoked with the provided arguments.

Screenshots

No response

Environment

  • Operating System: All macOS
  • Python version: All
  • Software versions:
    • Briefcase: 0.3.12

Logs

n/a

Additional context

See beeware/briefcase-macOS-app-template#7 for the original report on macOS; the fault is with the stub binary, so the fix needs to be on the Xcode template. Any fix here will be inherited by the app template.

One possible solution would be to add some logic to the stub binary to inspect to see if the parent process is "self"; if so, the execution of the app should be modified to behave as if it were a normal Python binary.

Any solution should also be ported to Linux (beeware/briefcase-linux-flatpak-template#10) and Windows (beeware/briefcase-windows-VisualStudio-template#8).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA crash or error in behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions