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

[Windows] briefcase run Spawns Multple Windows in existence of Daemon Process #2007

Closed
Pairman opened this issue Sep 26, 2024 · 2 comments
Closed
Labels
bug A crash or error in behavior.

Comments

@Pairman
Copy link
Contributor

Pairman commented Sep 26, 2024

Describe the bug

I'm working on a project where it needs aiohttp to run a web server. It must be be ran in a main thread, so I have to put its logic under a daemon process with multiprocessing.Process(target = ..., daemon = True).

It totally works on Android, Ubuntu on Fedora, except Windows. My users on Windows have reported that they cannot access the web server with the built-in WebView nor their browsers, showing ERR_CONNECTION_REFUSED, which indicates that the web server isn't started properly.

So I took a look into this using briefcase dev and briefcase run -u. If I use briefcase dev, the web broswer (or daemon process) can be started normally and can be accessed. However with briefcase run -u, my APP will be launched for multiple times indefinitely, resulting in a ton of windows, and the web server cannot be accessed. And if I remove the multiprocessing.Process(...).start(), briefcase won't spawn me numerous windows. The .msi from briefcase package won't spawn multiple windows, but as I said, its web server cannot be started normally too.

I reproduced exactly these bugs in the following simplified setup. Note: The daemon = True for multiprocessing.Process is not necessary for this bug to happen. And a simple time.sleep() in the daemon process also causes these bug.

Hope this can be fixed. Thanks.

Steps to reproduce

  1. On Windows
  2. Create a simple briefcase project and run a daemon process with multiprocessing.Process along with the main GUI.
  3. Execute briefcase run -u, APP windows will be spawned non-stop. And the thing in the daemon process won't working properly.
  4. Install the .msi from briefcase package, the thing in the daemon process won't working properly too.

Expected behavior

  1. briefcase run shouldn't create multiple windows for my APP.
  2. Things in the daemon process (web server for me) should work normally when using briefcase run or the installed package, on Windows.

Screenshots

No response

Environment

OS: Windows-11-10.0.22631-SP0 AMD64
Python exe: C:\Users\Pairman\Downloads\bw\venv\Scripts\python.exe
Python version: 3.12.2 (tags/v3.12.2:6abddd9, Feb 6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)]
Virtual env: True
Briefcase: 0.3.19
Toga: toga-0.4.7 toga-core-0.4.7 toga-winforms-0.4.7

Logs

briefcase create:

Date/Time:       2024-09-26 20:00:36 
Command line:    C:\Users\Pairman\Downloads\bw\venv\Scripts\briefcase create --log

OS Release:      Windows 11
OS Version:      10.0.22631
Architecture:    AMD64
Platform:        Windows-11-10.0.22631-SP0

Python exe:      C:\Users\Pairman\Downloads\bw\venv\Scripts\python.exe
Python version:  3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)]
Virtual env:     True
Conda env:       False

Briefcase:       0.3.19
Target platform: windows
Target format:   app

Environment Variables:
	ALLUSERSPROFILE=C:\ProgramData
	APPDATA=C:\Users\Pairman\AppData\Roaming
	ASL.LOG=Destination=file
	COMMONPROGRAMFILES=C:\Program Files\Common Files
	COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
	COMMONPROGRAMW6432=C:\Program Files\Common Files
	COMPUTERNAME=PAIRFACE
	COMSPEC=C:\Windows\system32\cmd.exe
	DRIVERDATA=C:\Windows\System32\Drivers\DriverData
	HOMEDRIVE=C:
	HOMEPATH=\Users\Pairman
	LOCALAPPDATA=C:\Users\Pairman\AppData\Local
	LOGONSERVER=\\PAIRFACE
	NUMBER_OF_PROCESSORS=8
	ONEDRIVE=C:\Users\Pairman\OneDrive
	OS=Windows_NT
	PATH=C:\Users\Pairman\Downloads\bw\venv\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\WireGuard\;C:\Program Files\nodejs\;C:\Users\Pairman\scoop\shims;C:\Users\Pairman\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\Pairman\AppData\Local\Programs\Python\Python312\;C:\Users\Pairman\AppData\Local\Microsoft\WindowsApps;C:\Users\Pairman\AppData\Local\Programs\Fiddler;C:\Users\Pairman\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Pairman\AppData\Local\Programs\platform-tools;C:\Users\Pairman\AppData\Roaming\dragonwell21\bin;C:\Users\Pairman\Downloads\ios-webkit-debug-proxy-1.9.1-win64-bin;C:\Users\Pairman\AppData\Roaming\npm
	PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
	PROCESSOR_ARCHITECTURE=AMD64
	PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
	PROCESSOR_LEVEL=6
	PROCESSOR_REVISION=8c01
	PROGRAMDATA=C:\ProgramData
	PROGRAMFILES=C:\Program Files
	PROGRAMFILES(X86)=C:\Program Files (x86)
	PROGRAMW6432=C:\Program Files
	PSMODULEPATH=C:\Users\Pairman\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
	PUBLIC=C:\Users\Public
	SESSIONNAME=Console
	SYSTEMDRIVE=C:
	SYSTEMROOT=C:\Windows
	TEMP=C:\Users\Pairman\AppData\Local\Temp
	TMP=C:\Users\Pairman\AppData\Local\Temp
	USERDOMAIN=PAIRFACE
	USERDOMAIN_ROAMINGPROFILE=PAIRFACE
	USERNAME=Pairman
	USERPROFILE=C:\Users\Pairman
	VIRTUAL_ENV=C:\Users\Pairman\Downloads\bw\venv
	VIRTUAL_ENV_PROMPT=venv
	WINDIR=C:\Windows
	WSLENV=WT_SESSION:WT_PROFILE_ID:
	WT_PROFILE_ID={61c54bbd-c2c6-5271-96e7-009a87ff44bf}
	WT_SESSION=5ad5d309-16eb-4ce3-8014-e6af6d8d4cb3
	_OLD_VIRTUAL_PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\WireGuard\;C:\Program Files\nodejs\;C:\Users\Pairman\scoop\shims;C:\Users\Pairman\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\Pairman\AppData\Local\Programs\Python\Python312\;C:\Users\Pairman\AppData\Local\Microsoft\WindowsApps;C:\Users\Pairman\AppData\Local\Programs\Fiddler;C:\Users\Pairman\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Pairman\AppData\Local\Programs\platform-tools;C:\Users\Pairman\AppData\Roaming\dragonwell21\bin;C:\Users\Pairman\Downloads\ios-webkit-debug-proxy-1.9.1-win64-bin;C:\Users\Pairman\AppData\Roaming\npm

pyproject.toml:
# This project was generated with 0.3.19 using template: https://github.com/beeware/briefcase-template@v0.3.19
[tool.briefcase]
project_name = "Hello World"
bundle = "com.example"
version = "0.0.1"
url = "https://example.com/helloworld"
license.file = "LICENSE"
author = "Jane Developer"
author_email = "jane@example.com"

[tool.briefcase.app.helloworld]
formal_name = "Hello World"
description = "Hello World"
long_description = "Hello World"
sources = ["src/helloworld"]
requires = ["aiohttp", "toga"]

[tool.briefcase.app.helloworld.windows]
requires = ["toga-winforms~=0.4.5"]

Briefcase Log:
[19:59:55]                                                                                                                                                             create.py:884
           [helloworld] Generating application template...                                                                                                             create.py:884
           Assigning helloworld an application GUID of 93bbf2ae-12d0-580c-aeb0-965dc4c04b69                                                                           __init__.py:91
           Using app template: https://github.com/beeware/briefcase-windows-app-template.git, branch v0.3.19                                                            base.py:1090
[20:00:06] Cmd('git') failed due to: exit code(128)                                                                                                                      base.py:977
             cmdline: git fetch -v -- origin                                                                                                                             base.py:977
             stderr: 'fatal: unable to access 'https://github.com/beeware/briefcase-windows-app-template.git/': OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0'            base.py:977
                                                                                                                                                                         base.py:978
           *************************************************************************                                                                                     base.py:978
           ** WARNING: Unable to update template                                  **                                                                                     base.py:978
           *************************************************************************                                                                                     base.py:978
                                                                                                                                                                         base.py:978
               Briefcase is unable the update the application template. This                                                                                             base.py:978
               may be because your computer is currently offline. Briefcase will                                                                                         base.py:978
               use existing template without updating.                                                                                                                   base.py:978
                                                                                                                                                                         base.py:978
           *************************************************************************                                                                                     base.py:978
           Using existing template (sha 8f153808429f87d7df42baf69db1d1c60fd62a88, updated Tue Jun 11 21:41:21 2024)                                                      base.py:996
                                                                                                                                                                       create.py:887
           [helloworld] Installing support package...                                                                                                                  create.py:887
           Using support package https://www.python.org/ftp/python/3.12.1/python-3.12.1-embed-amd64.zip                                                                create.py:354
[20:00:07] python-3.12.1-embed-amd64.zip already downloaded                                                                                                              file.py:147
           Unpacking support package... started                                                                                                                        create.py:269
[20:00:08] Unpacking support package... done                                                                                                                           create.py:269
                                                                                                                                                                       create.py:898
           [helloworld] Installing stub binary...                                                                                                                      create.py:898
           Using stub binary https://briefcase-support.s3.amazonaws.com/python/3.12/windows/GUI-Stub-3.12-b5.zip                                                       create.py:465
[20:00:10] GUI-Stub-3.12-b5.zip already downloaded                                                                                                                       file.py:147
           Installing stub binary... started                                                                                                                           create.py:410
           Installing stub binary... done                                                                                                                              create.py:410
                                                                                                                                                                       create.py:905
           [helloworld] Installing application code...                                                                                                                 create.py:905
           Installing src/helloworld... started                                                                                                                        create.py:685
           Installing src/helloworld... done                                                                                                                           create.py:685
                                                                                                                                                                       create.py:908
           [helloworld] Installing requirements...                                                                                                                     create.py:908
           Installing app requirements... started                                                                                                                      create.py:622
                                                                                                                                                                   subprocess.py:827
           >>> Running Command:                                                                                                                                    subprocess.py:827
           >>>     'C:\Users\Pairman\Downloads\bw\venv\Scripts\python.exe' -u -X utf8 -m pip install --disable-pip-version-check --no-python-version-warning       subprocess.py:827
           --upgrade --no-user '--target=C:\Users\Pairman\Downloads\bw\helloworld\build\helloworld\windows\app\src\app_packages' aiohttp toga                                       
           'toga-winforms~=0.4.5'                                                                                                                                                   
           >>> Working Directory:                                                                                                                                  subprocess.py:827
           >>>     C:\Users\Pairman\Downloads\bw\helloworld                                                                                                        subprocess.py:827
[20:00:14] Collecting aiohttp                                                                                                                                      subprocess.py:195
             Using cached aiohttp-3.10.6-cp312-cp312-win_amd64.whl.metadata (7.8 kB)                                                                               subprocess.py:195
[20:00:15] Collecting toga                                                                                                                                         subprocess.py:195
             Using cached toga-0.4.7-py3-none-any.whl.metadata (4.1 kB)                                                                                            subprocess.py:195
           Collecting toga-winforms~=0.4.5                                                                                                                         subprocess.py:195
             Using cached toga_winforms-0.4.7-py3-none-any.whl.metadata (3.2 kB)                                                                                   subprocess.py:195
[20:00:16] Collecting aiohappyeyeballs>=2.3.0 (from aiohttp)                                                                                                       subprocess.py:195
             Using cached aiohappyeyeballs-2.4.0-py3-none-any.whl.metadata (5.9 kB)                                                                                subprocess.py:195
           Collecting aiosignal>=1.1.2 (from aiohttp)                                                                                                              subprocess.py:195
             Using cached aiosignal-1.3.1-py3-none-any.whl.metadata (4.0 kB)                                                                                       subprocess.py:195
           Collecting attrs>=17.3.0 (from aiohttp)                                                                                                                 subprocess.py:195
             Using cached attrs-24.2.0-py3-none-any.whl.metadata (11 kB)                                                                                           subprocess.py:195
[20:00:17] Collecting frozenlist>=1.1.1 (from aiohttp)                                                                                                             subprocess.py:195
             Using cached frozenlist-1.4.1-cp312-cp312-win_amd64.whl.metadata (12 kB)                                                                              subprocess.py:195
[20:00:18] Collecting multidict<7.0,>=4.5 (from aiohttp)                                                                                                           subprocess.py:195
             Using cached multidict-6.1.0-cp312-cp312-win_amd64.whl.metadata (5.1 kB)                                                                              subprocess.py:195
[20:00:19] Collecting yarl<2.0,>=1.12.0 (from aiohttp)                                                                                                             subprocess.py:195
             Using cached yarl-1.12.1-cp312-cp312-win_amd64.whl.metadata (50 kB)                                                                                   subprocess.py:195
           Collecting pythonnet>=3.0.0 (from toga-winforms~=0.4.5)                                                                                                 subprocess.py:195
             Using cached pythonnet-3.0.4-py3-none-any.whl.metadata (6.6 kB)                                                                                       subprocess.py:195
[20:00:20] Collecting toga-core==0.4.7 (from toga-winforms~=0.4.5)                                                                                                 subprocess.py:195
             Using cached toga_core-0.4.7-py3-none-any.whl.metadata (5.4 kB)                                                                                       subprocess.py:195
           Collecting travertino>=0.3.0 (from toga-core==0.4.7->toga-winforms~=0.4.5)                                                                              subprocess.py:195
             Using cached travertino-0.3.0-py3-none-any.whl.metadata (4.3 kB)                                                                                      subprocess.py:195
[20:00:21] Collecting clr-loader<0.3.0,>=0.2.6 (from pythonnet>=3.0.0->toga-winforms~=0.4.5)                                                                       subprocess.py:195
             Using cached clr_loader-0.2.6-py3-none-any.whl.metadata (1.4 kB)                                                                                      subprocess.py:195
           Collecting idna>=2.0 (from yarl<2.0,>=1.12.0->aiohttp)                                                                                                  subprocess.py:195
             Using cached idna-3.10-py3-none-any.whl.metadata (10 kB)                                                                                              subprocess.py:195
[20:00:22] Collecting cffi>=1.13 (from clr-loader<0.3.0,>=0.2.6->pythonnet>=3.0.0->toga-winforms~=0.4.5)                                                           subprocess.py:195
             Using cached cffi-1.17.1-cp312-cp312-win_amd64.whl.metadata (1.6 kB)                                                                                  subprocess.py:195
           Collecting pycparser (from cffi>=1.13->clr-loader<0.3.0,>=0.2.6->pythonnet>=3.0.0->toga-winforms~=0.4.5)                                                subprocess.py:195
             Using cached pycparser-2.22-py3-none-any.whl.metadata (943 bytes)                                                                                     subprocess.py:195
           Using cached aiohttp-3.10.6-cp312-cp312-win_amd64.whl (378 kB)                                                                                          subprocess.py:195
           Using cached toga-0.4.7-py3-none-any.whl (3.3 kB)                                                                                                       subprocess.py:195
           Using cached toga_winforms-0.4.7-py3-none-any.whl (454 kB)                                                                                              subprocess.py:195
           Using cached toga_core-0.4.7-py3-none-any.whl (139 kB)                                                                                                  subprocess.py:195
           Using cached aiohappyeyeballs-2.4.0-py3-none-any.whl (12 kB)                                                                                            subprocess.py:195
           Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)                                                                                                  subprocess.py:195
           Using cached attrs-24.2.0-py3-none-any.whl (63 kB)                                                                                                      subprocess.py:195
           Using cached frozenlist-1.4.1-cp312-cp312-win_amd64.whl (50 kB)                                                                                         subprocess.py:195
           Using cached multidict-6.1.0-cp312-cp312-win_amd64.whl (28 kB)                                                                                          subprocess.py:195
           Using cached pythonnet-3.0.4-py3-none-any.whl (295 kB)                                                                                                  subprocess.py:195
           Using cached yarl-1.12.1-cp312-cp312-win_amd64.whl (110 kB)                                                                                             subprocess.py:195
           Using cached clr_loader-0.2.6-py3-none-any.whl (51 kB)                                                                                                  subprocess.py:195
           Using cached idna-3.10-py3-none-any.whl (70 kB)                                                                                                         subprocess.py:195
[20:00:23] Using cached travertino-0.3.0-py3-none-any.whl (16 kB)                                                                                                  subprocess.py:195
           Using cached cffi-1.17.1-cp312-cp312-win_amd64.whl (181 kB)                                                                                             subprocess.py:195
           Using cached pycparser-2.22-py3-none-any.whl (117 kB)                                                                                                   subprocess.py:195
[20:00:24] Installing collected packages: travertino, pycparser, multidict, idna, frozenlist, attrs, aiohappyeyeballs, yarl, toga-core, cffi, aiosignal,           subprocess.py:195
           clr-loader, aiohttp, pythonnet, toga-winforms, toga                                                                                                                      
[20:00:35] Successfully installed aiohappyeyeballs-2.4.0 aiohttp-3.10.6 aiosignal-1.3.1 attrs-24.2.0 cffi-1.17.1 clr-loader-0.2.6 frozenlist-1.4.1 idna-3.10       subprocess.py:195
           multidict-6.1.0 pycparser-2.22 pythonnet-3.0.4 toga-0.4.7 toga-core-0.4.7 toga-winforms-0.4.7 travertino-0.3.0 yarl-1.12.1                                               
[20:00:36] >>> Return code: 0                                                                                                                                      subprocess.py:827
           Installing app requirements... done                                                                                                                         create.py:622
                                                                                                                                                                       create.py:911
           [helloworld] Installing application resources...                                                                                                            create.py:911
                                                                                                                                                                       create.py:914
           [helloworld] Removing unneeded app content...                                                                                                               create.py:914
           Removing unneeded app bundle content... started                                                                                                             create.py:848
           Removing directory src\app_packages\__pycache__                                                                                                             create.py:855
           Removing directory src\app_packages\aiohappyeyeballs\__pycache__                                                                                            create.py:855
           Removing directory src\app_packages\aiohttp\__pycache__                                                                                                     create.py:855
           Removing directory src\app_packages\aiosignal\__pycache__                                                                                                   create.py:855
           Removing directory src\app_packages\attr\__pycache__                                                                                                        create.py:855
           Removing directory src\app_packages\attrs\__pycache__                                                                                                       create.py:855
           Removing directory src\app_packages\cffi\__pycache__                                                                                                        create.py:855
           Removing directory src\app_packages\clr_loader\__pycache__                                                                                                  create.py:855
           Removing directory src\app_packages\frozenlist\__pycache__                                                                                                  create.py:855
           Removing directory src\app_packages\idna\__pycache__                                                                                                        create.py:855
           Removing directory src\app_packages\multidict\__pycache__                                                                                                   create.py:855
           Removing directory src\app_packages\pycparser\__pycache__                                                                                                   create.py:855
           Removing directory src\app_packages\pythonnet\__pycache__                                                                                                   create.py:855
           Removing directory src\app_packages\toga\__pycache__                                                                                                        create.py:855
           Removing directory src\app_packages\toga_winforms\__pycache__                                                                                               create.py:855
           Removing directory src\app_packages\travertino\__pycache__                                                                                                  create.py:855
           Removing directory src\app_packages\yarl\__pycache__                                                                                                        create.py:855
           Removing directory src\app_packages\clr_loader\ffi\__pycache__                                                                                              create.py:855
           Removing directory src\app_packages\clr_loader\util\__pycache__                                                                                             create.py:855
           Removing directory src\app_packages\pycparser\ply\__pycache__                                                                                               create.py:855
           Removing directory src\app_packages\toga\constants\__pycache__                                                                                              create.py:855
           Removing directory src\app_packages\toga\hardware\__pycache__                                                                                               create.py:855
           Removing directory src\app_packages\toga\plugins\__pycache__                                                                                                create.py:855
           Removing directory src\app_packages\toga\resources\__pycache__                                                                                              create.py:855
           Removing directory src\app_packages\toga\sources\__pycache__                                                                                                create.py:855
           Removing directory src\app_packages\toga\style\__pycache__                                                                                                  create.py:855
           Removing directory src\app_packages\toga\widgets\__pycache__                                                                                                create.py:855
           Removing directory src\app_packages\toga_winforms\hardware\__pycache__                                                                                      create.py:855
           Removing directory src\app_packages\toga_winforms\libs\__pycache__                                                                                          create.py:855
           Removing directory src\app_packages\toga_winforms\widgets\__pycache__                                                                                       create.py:855
           Removing unneeded app bundle content... done                                                                                                                create.py:848
                                                                                                                                                                       create.py:917
           [helloworld] Created build\helloworld\windows\app                                                                                                           create.py:917
           Saving log... started                                                                                                                                      console.py:390

briefcase run -u (stopped with ctrl + c):

Date/Time:       2024-09-26 20:10:03 
Command line:    C:\Users\Pairman\Downloads\bw\venv\Scripts\briefcase run -u --log

OS Release:      Windows 11
OS Version:      10.0.22631
Architecture:    AMD64
Platform:        Windows-11-10.0.22631-SP0

Python exe:      C:\Users\Pairman\Downloads\bw\venv\Scripts\python.exe
Python version:  3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)]
Virtual env:     True
Conda env:       False

Briefcase:       0.3.19
Target platform: windows
Target format:   app

Environment Variables:
	ALLUSERSPROFILE=C:\ProgramData
	APPDATA=C:\Users\Pairman\AppData\Roaming
	ASL.LOG=Destination=file
	COMMONPROGRAMFILES=C:\Program Files\Common Files
	COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
	COMMONPROGRAMW6432=C:\Program Files\Common Files
	COMPUTERNAME=PAIRFACE
	COMSPEC=C:\Windows\system32\cmd.exe
	DRIVERDATA=C:\Windows\System32\Drivers\DriverData
	HOMEDRIVE=C:
	HOMEPATH=\Users\Pairman
	LOCALAPPDATA=C:\Users\Pairman\AppData\Local
	LOGONSERVER=\\PAIRFACE
	NUMBER_OF_PROCESSORS=8
	ONEDRIVE=C:\Users\Pairman\OneDrive
	OS=Windows_NT
	PATH=C:\Users\Pairman\Downloads\bw\venv\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\WireGuard\;C:\Program Files\nodejs\;C:\Users\Pairman\scoop\shims;C:\Users\Pairman\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\Pairman\AppData\Local\Programs\Python\Python312\;C:\Users\Pairman\AppData\Local\Microsoft\WindowsApps;C:\Users\Pairman\AppData\Local\Programs\Fiddler;C:\Users\Pairman\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Pairman\AppData\Local\Programs\platform-tools;C:\Users\Pairman\AppData\Roaming\dragonwell21\bin;C:\Users\Pairman\Downloads\ios-webkit-debug-proxy-1.9.1-win64-bin;C:\Users\Pairman\AppData\Roaming\npm
	PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
	PROCESSOR_ARCHITECTURE=AMD64
	PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
	PROCESSOR_LEVEL=6
	PROCESSOR_REVISION=8c01
	PROGRAMDATA=C:\ProgramData
	PROGRAMFILES=C:\Program Files
	PROGRAMFILES(X86)=C:\Program Files (x86)
	PROGRAMW6432=C:\Program Files
	PSMODULEPATH=C:\Users\Pairman\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
	PUBLIC=C:\Users\Public
	SESSIONNAME=Console
	SYSTEMDRIVE=C:
	SYSTEMROOT=C:\Windows
	TEMP=C:\Users\Pairman\AppData\Local\Temp
	TMP=C:\Users\Pairman\AppData\Local\Temp
	USERDOMAIN=PAIRFACE
	USERDOMAIN_ROAMINGPROFILE=PAIRFACE
	USERNAME=Pairman
	USERPROFILE=C:\Users\Pairman
	VIRTUAL_ENV=C:\Users\Pairman\Downloads\bw\venv
	VIRTUAL_ENV_PROMPT=venv
	WINDIR=C:\Windows
	WSLENV=WT_SESSION:WT_PROFILE_ID:
	WT_PROFILE_ID={61c54bbd-c2c6-5271-96e7-009a87ff44bf}
	WT_SESSION=5ad5d309-16eb-4ce3-8014-e6af6d8d4cb3
	_OLD_VIRTUAL_PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\WireGuard\;C:\Program Files\nodejs\;C:\Users\Pairman\scoop\shims;C:\Users\Pairman\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\Pairman\AppData\Local\Programs\Python\Python312\;C:\Users\Pairman\AppData\Local\Microsoft\WindowsApps;C:\Users\Pairman\AppData\Local\Programs\Fiddler;C:\Users\Pairman\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Pairman\AppData\Local\Programs\platform-tools;C:\Users\Pairman\AppData\Roaming\dragonwell21\bin;C:\Users\Pairman\Downloads\ios-webkit-debug-proxy-1.9.1-win64-bin;C:\Users\Pairman\AppData\Roaming\npm

pyproject.toml:
# This project was generated with 0.3.19 using template: https://github.com/beeware/briefcase-template@v0.3.19
[tool.briefcase]
project_name = "Hello World"
bundle = "com.example"
version = "0.0.1"
url = "https://example.com/helloworld"
license.file = "LICENSE"
author = "Jane Developer"
author_email = "jane@example.com"

[tool.briefcase.app.helloworld]
formal_name = "Hello World"
description = "Hello World"
long_description = "Hello World"
sources = ["src/helloworld"]
requires = ["aiohttp", "toga"]

[tool.briefcase.app.helloworld.windows]
requires = ["toga-winforms~=0.4.5"]

Briefcase Log:
[20:09:55]                                                                                                                                                         windows_sdk.py:82
           [Windows SDK] Finding Suitable Installation...                                                                                                          windows_sdk.py:82
                                                                                                                                                                        update.py:45
           [helloworld] Updating application code...                                                                                                                    update.py:45
           Installing src/helloworld... started                                                                                                                        create.py:685
           Installing src/helloworld... done                                                                                                                           create.py:685
                                                                                                                                                                        update.py:74
           [helloworld] Removing unneeded app content...                                                                                                                update.py:74
           Removing unneeded app bundle content... started                                                                                                             create.py:848
           Removing unneeded app bundle content... done                                                                                                                create.py:848
                                                                                                                                                                        update.py:77
           [helloworld] Application updated.                                                                                                                            update.py:77
                                                                                                                                                                           app.py:55
           [helloworld] Building App...                                                                                                                                    app.py:55
           Setting stub app details... started                                                                                                                             app.py:95
                                                                                                                                                                   subprocess.py:827
           >>> Running Command:                                                                                                                                    subprocess.py:827
           >>>     'C:\Users\Pairman\AppData\Local\BeeWare\briefcase\Cache\tools\rcedit-x64.exe' 'src\Hello World.exe' --set-version-string CompanyName 'Jane      subprocess.py:827
           Developer' --set-version-string FileDescription 'Hello World' --set-version-string FileVersion 0.0.1 --set-version-string InternalName helloworld                        
           --set-version-string OriginalFilename 'Hello World.exe' --set-version-string ProductName 'Hello World' --set-version-string ProductVersion 0.0.1                         
           --set-icon icon.ico                                                                                                                                                      
           >>> Working Directory:                                                                                                                                  subprocess.py:827
           >>>     C:\Users\Pairman\Downloads\bw\helloworld\build\helloworld\windows\app                                                                           subprocess.py:827
           >>> Return code: 0                                                                                                                                      subprocess.py:827
           Setting stub app details... done                                                                                                                                app.py:95
                                                                                                                                                                         build.py:80
           [helloworld] Built build\helloworld\windows\app\src\Hello World.exe                                                                                           build.py:80
                                                                                                                                                                          run.py:246
           [helloworld] Starting app...                                                                                                                                   run.py:246
                                                                                                                                                                   subprocess.py:827
           >>> Running Command:                                                                                                                                    subprocess.py:827
           >>>     'C:\Users\Pairman\Downloads\bw\helloworld\build\helloworld\windows\app\src\Hello World.exe'                                                     subprocess.py:827
           >>> Working Directory:                                                                                                                                  subprocess.py:827
           >>>     C:\Users\Pairman                                                                                                                                subprocess.py:827
[20:09:56] ===========================================================================                                                                                    run.py:171
[20:10:03] Stopping...                                                                                                                                             subprocess.py:761
           Saving log... started                                                                                                                                      console.py:390

Additional context

Simplified code to reproduce these bugs:

File hierarchy:

LICENSE
pyproject.toml
src/helloworld/__init__.py
src/helloworld/__main__.py

__init__.py:

from aiohttp.web import Application, Response, run_app
from toga import App as TogaApp, Box, MainWindow, Label

async def index(req):
        return Response(text = "OK")

def start_server():
        app = Application()
        app.router.add_get("/", index)
        run_app(app, host = "localhost", port = 5001)

class MyApp(TogaApp):
        def startup(self):
                self.main_window = MainWindow(title = self.formal_name)
                self.main_window.content = Box(children = (Label("MyApp"), ))
                self.main_window.show()

__main__.py:

from multiprocessing import Process
from helloworld import MyApp

if __name__ == "__main__":
	# from time import sleep
	# Process(target = sleep, args = (120,)).start()
	from helloworld import start_server
	Process(target = start_server, daemon = True).start()
	MyApp().main_loop()

pyproject.toml:

# This project was generated with 0.3.19 using template: https://github.com/beeware/briefcase-template@v0.3.19
[tool.briefcase]
project_name = "Hello World"
bundle = "com.example"
version = "0.0.1"
url = "https://example.com/helloworld"
license.file = "LICENSE"
author = "Jane Developer"
author_email = "jane@example.com"

[tool.briefcase.app.helloworld]
formal_name = "Hello World"
description = "Hello World"
long_description = "Hello World"
sources = ["src/helloworld"]
requires = ["aiohttp", "toga"]

[tool.briefcase.app.helloworld.windows]
requires = ["toga-winforms~=0.4.5"]
@Pairman Pairman added the bug A crash or error in behavior. label Sep 26, 2024
@mhsmith
Copy link
Member

mhsmith commented Sep 26, 2024

multiprocessing is mostly unsupported in the current version of Briefcase (beeware/briefcase-windows-VisualStudio-template#8). However, there's probably a way to run your server in a thread instead of a separate process. See these StackOverflow questions for advice:

@freakboy3742
Copy link
Member

Closing on the basis that this is an issue with the support package/template, not Briefcase itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

3 participants