os.path.exists crashes pyodide when using PROXYFS
See original GitHub issue🐛 Bug
When file_path is in a directory that uses PROXYFS, running os.path.exists(file_path) returns True when the file exists but crashes pyodide when it does not.
To Reproduce
index.html:
<!DOCTYPE html>
<html>
<body>
<script> new Worker('webworker.js'); </script>
</body>
</html>
webworker.js:
importScripts("https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js");
async function loadPyodideAndPackages() {
self.pyodide1 = await loadPyodide();
self.pyodide2 = await loadPyodide();
await self.pyodide1.FS.mkdir("/dir1");
await self.pyodide2.FS.mkdir("/dir2");
await self.pyodide2.FS.mount(self.pyodide2.FS.filesystems.PROXYFS, {
root: "/dir1",
fs: self.pyodide1.FS
}, "/dir2");
// this code generates the expected output True False
await self.pyodide1.runPython(`
import os
with open('/dir1/foo.txt', 'w') as f:
f.write('hello')
print(os.path.exists('/dir1/foo.txt'));
print(os.path.exists('/dir1/bar.txt'));
`);
// this code outputs True but then crashes on the last line
await self.pyodide2.runPython(`
import os
print(os.path.exists('/dir2/foo.txt'));
print(os.path.exists('/dir2/bar.txt'));
`);
}
let pyodideReadyPromise = loadPyodideAndPackages();
The error message in the console is the following:
Expected behavior
The code above should have produced the output
True
False
True
False
instead of crashing.
Environment
- Pyodide Version: v0.21.3
- Browser version: Chrome 105.0.5195.125, Firefox 105.0
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Python file existence checks loop crashes - unless I add a ...
If I step through the loop with a debugger, the code works fine, but if I just run the application, it crashes on...
Read more >Release 0.21.3 unknown
Python code is run using the pyodide.runPython function. It takes as input a string of Python code. If the code ends in an...
Read more >Failed to import skimage in a web-worker · Issue #917
After closing #253 with #866, we should be able to use scikit-image, however, when I try to import it (from cdn.jsdelivr.net/pyodide/dev/full/) ...
Read more >Changelog — Python 3.11.1 documentation
gh-96192: Fix handling of bytes path-like objects in os.ismount() . ... The functions exist on the API by accident through inheritance and will...
Read more >pytest Documentation
variable does not exist. Using monkeypatch both paths can be safely tested without impacting the running environment:.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the report @omert. I believe that this is an upstream bug in Emscripten @scb100.
I think you mentioned the wrong person?