r0x0r/pywebview

pywebview multiprocessing with pyinstaller

Liripo opened this issue · 3 comments

Specification

  • pywebview version: 5.3
  • operating system: windowns
  • web renderer: default

question

When I compile this program using pyinstaller, a duplicate window opens.

import webview
import multiprocessing

def test():
    while True:
        1

def on_closed(process):
    if process.is_alive():
        process.terminate()
        process.join()
    return None

process = multiprocessing.Process(target=test)
process.start()

index_html = "index.html"
win = webview.create_window('test!', str(index_html))
win.events.closed += lambda: on_closed(process)
webview.start(http_server=True,debug=False)
pyinstaller --onefile .\test.py
.\dist\test.exe

error gif:
PixPin_2024-10-18_17-18-25

Maybe wrapping top level code in if __name__ == '__main__' helps

@Sped0n Thank you.