Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing application does not work in Mac #156

Open
malkarouri opened this issue Aug 30, 2024 · 3 comments
Open

Closing application does not work in Mac #156

malkarouri opened this issue Aug 30, 2024 · 3 comments

Comments

@malkarouri
Copy link

malkarouri commented Aug 30, 2024

I am using Python 3.12 on MacOS 14.6, using FastAPI. I am using the exact code to close application as shown in the application.
The browser is not closed on pressing the Close button. The server shuts down, but Chrome stays open with a clear page (or whatever the Close function returns after calling close_application.

I can trace the issue to the way the run function works in FlaskUI for MacOS (Darwin). It seems that the run functions starts a new process. The value of the global variable FLASKWEBGUI_BROWSER_PROCESS is not shared between the old and new process, causing the call to close_application to find the process value as None and not terminate it.

@ClimenteA
Copy link
Owner

Hi,

Thank you for opening this issue. I don't have a Mac to test this, but try this: in the flaskwebgui.py source file on line
256 add the following:

if OPERATING_SYSTEM == "darwin":
    multiprocessing.set_start_method("fork")

before FLASKWEBGUI_BROWSER_PROCESS = subprocess.Popen(self.browser_command).

Please tell me if that fixes the issue or not.

@ClimenteA
Copy link
Owner

I added this change on the new version, not tested (I don't own a mac). But, please reopen this issue if it's not solved.

@haishiniu
Copy link

I added this change on the new version, not tested (I don't own a mac). But, please reopen this issue if it's not solved.我在新版本上添加了此更改,未经测试(我没有 mac)。但是,如果此问题未解决,请重新打开。

I believe this issue still remains unresolved as it hasn't fully addressed my problem. I suggest reopening this issue for further discussion and potential fixes.

i test result:
python 3.10.3
sys:macos 10.15.7
code error:
File "/.pyenv/versions/3.10.3/lib/python3.10/threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "/venv/lib/python3.10/site-packages/flaskwebgui.py", line 265, in start_browser
multiprocessing.set_start_method("fork")
File "/.pyenv/versions/3.10.3/lib/python3.10/multiprocessing/context.py", line 243, in set_start_method
raise RuntimeError('context has already been set')

@ClimenteA ClimenteA reopened this Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants