[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pyz and concurrent.futures

I have two apps, one GUI one console, both using PySide2 bindings to Qt 5.
Both use concurrent.futures and a processing pool to spread their work over multiple CPUs.

I've written my own deployment script (since I can't get a successfull deploy with cx-freeze, py2exe, or pyinstaller) which creates this structure:

myapp/python/ # copy of Python 3.6 i.e., WinPython's python-3.6.7 dir
myapp/*.DLL # some custom and commercial DLLs the apps depend on

I create the .pyz by copying myapp's .py files, running python3 -m compileall -b on the copied dir, then deleting all the original .py files, then renaming as and then zipping it all up as myapp.pyz.

I can then run the programs using .bat files like this:

Console app:
"%~dp0\python\python.exe" "%~dp0\myapp.pyz" %*

GUI app:
"%~dp0\python\pythonw.exe" "%~dp0\myapp.pyz" %*

The GUI app works fine.

One significant difference is that the GUI app has two threads, the main thread running the GUI and a worker thread in which the calls to concurrent.futures process pool are made. Whereas the console app uses a single thread.

Another difference is that the GUI app has an event loop and the console app doesn't.

The console app works fine in the dev dir, but silently fails when run as a pyz.
And it fails executing the same code as the GUI app (they share many modules).

Has anyone encountered this issue before and have a solution?

I plan to try to use two threads for the console app to see if that helps; but I'd still like to understand what is causing the problem.