indygreg / indygreg/PyOxidizer
Incorrect python call in MainPythonInterpreter::run_multiprocessing
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 256
- PR merge metrics
- No merged PRs in 30d
Description
While messing with the multiprocessing `spawn` start method on linux, I got this error:
```python-tb
File "multiprocessing.spawn", line 115, in spawn_main
TypeError: 'dict' object cannot be interpreted as an int
```
Even though I read in the [docs](https://pyoxidizer.readthedocs.io/en/stable/pyoxidizer_packaging_multiprocessing.html#spawn-only-works-on-windows-with-pyoxidizer) that:
> the spawn start method is known to be buggy with PyOxidizer except on Windows
.., I noticed what seems to be a bug in [MainPythonInterpreter::run_multiprocessing](https://docs.rs/pyembed/latest/pyembed/struct.MainPythonInterpreter.html#method.run_multiprocessing):
https://github.com/indygreg/PyOxidizer/blob/e063d3d6a9519e1b10e35b5117392cd9980de0fe/pyembed/src/interpreter.rs#L563
This effectively calls `spawn_main(kwargs)`. Shouldn't this be `spawn_main(**kwargs)` instead?
I built the project with this diff and it seems to fix my issue:
```diff
diff --git a/pyembed/src/interpreter.rs b/pyembed/src/interpreter.rs
index 8f1deb3f..7fc9954a 100644
--- a/pyembed/src/interpreter.rs
+++ b/pyembed/src/interpreter.rs
@@ -560,7 +560,7 @@ impl<'interpreter, 'resources> MainPythonInterpreter<'interpreter, 'resources> {
}
let spawn_module = py.import("multiprocessing.spawn")?;
- spawn_module.getattr("spawn_main")?.call1((kwargs,))?;
+ spawn_module.getattr("spawn_main")?.call((), Some(kwargs))?;
Ok(0)
})
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in pyembed/src/interpreter.rs at MainPythonInterpreter::run_multiprocessing and inspect the call to multiprocessing.spawn.spawn_main. Reproduce the Linux multiprocessing spawn case described in the issue and verify that the call no longer produces the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100