Skip to content

Panic when using Windows GUI app #5690

Open
@marcomq

Description

@marcomq

Summary

I tried to use RustPython in a windows GUI app, so that python code is running in the background and the result is displayed in a GUI. Unfortunately, it seems that stdin/stdout is required. I get a essential initialization failed panic error

 Error in sys.excepthook:
lost sys.stderr
RuntimeError: lost sys.stderr
Original exception was:
lost sys.stderr
OSError: (9, 'Das Handle ist ungültig. (os error 6)')

thread 'main' panicked at C:\Users\MyUser\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustpython-vm-0.4.0\src\vm\mod.rs:334:30:
essential initialization failed

I also have a sample tauri application here that can replicate the issue:
https://github.com/marcomq/tauri-plugin-python/tree/main/examples/plain-javascript

The gui is preventing the console with

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

I could also uncomment this line, but this would then always show a console in the background of the windows app, which is kind of a very ugly workaround.
I will check if I can maybe fix it locally, but I just wanted to create this issue first for documentation.

Expected

It would be nice if it wouldn't be required to have a console, similar to wasm/wasi mode.

Actual

The issue can only be replicated on windows release without console, so there is probably no real error visible and the application just doesn't start up.

Python Documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions