Message258895
A pyinstaller 3.0 frozen .exe Python 2.7.10 program under Windows 7 that uses a multiprocessing.Queue to send things to a multiprocessing.Process leads to the process getting access-is-denied exceptions on every q.get() call.
And, when the program can't exit. Or leaves a dangling process for every Process.
An unsatisfying fix for this is to put the following code somewhere in the program:
"""
Do what must be done to make multiprocessing work in .exe files.
This involves monkey patching multiprocessing.forking under Windows
so when the a program using a multiprocessing.Process exits,
there won't be processes left running.
Hint from http://stackoverflow.com/questions/33764448/pathos-multiprocessing-pipe-and-queue-on-windows
. The bottom line is we get "access is denied" when trying
. to get from the multiprocessing.Queue when we're an .exe file.
. So, in multiprocessing.forking.duplicate(),
. we change 'inheritable' to default to True
. from the normal code's False.
"""
import sys
import multiprocessing
import multiprocessing.forking
#
#
#
#
def duplicate(handle, target_process = None, inheritable = True) :
return(multiprocessing.forking.kludge_to_fix_dangling_processes(handle, target_process, inheritable))
if (not hasattr(multiprocessing.forking, 'kludge_to_fix_dangling_processes')) and (sys.platform == 'win32') :
multiprocessing.forking.kludge_to_fix_dangling_processes = multiprocessing.forking.duplicate
multiprocessing.forking.duplicate = duplicate |
|
Date |
User |
Action |
Args |
2016-01-25 02:54:45 | alex_python_org | set | recipients:
+ alex_python_org |
2016-01-25 02:54:44 | alex_python_org | set | messageid: <1453690484.95.0.111987955887.issue26195@psf.upfronthosting.co.za> |
2016-01-25 02:54:44 | alex_python_org | link | issue26195 messages |
2016-01-25 02:54:42 | alex_python_org | create | |
|