beeware / beeware/briefcase-windows-VisualStudio-template

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

Open
#8 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
7
Forks
22
Avg merge
18h 41m
Merged PRs (30d)
9

Description

### Describe the bug

The stub binary used to start an app is an effective replacement for the `python.exe` 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 Windows 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 Windows
- Python version: All
- Software versions:
- Briefcase: 0.3.12

### Logs

n/a

### Additional context

See https://github.com/beeware/briefcase-macOS-app-template/issues/7 for an analogous report on macOS.

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 macOS (beeware/briefcase-macOS-Xcode-template#20) and Linux (beeware/briefcase-linux-flatpak-template#10)

Contributor guide

Open the contributing guide

Research direction

Start by generating a Windows app and reproducing multiprocessing spawn or a subprocess call through sys.executable, then inspect how the stub binary launches the app. Compare the analogous macOS report and the referenced macOS and Linux template issues. Done means sys.executable launches the requested child entry point correctly on Windows, with the corresponding behavior addressed in the other templates.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
build-system, desktop
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.