This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alex_python_org
Recipients alex_python_org
Date 2016-01-25.02:54:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1453690484.95.0.111987955887.issue26195@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-01-25 02:54:45alex_python_orgsetrecipients: + alex_python_org
2016-01-25 02:54:44alex_python_orgsetmessageid: <1453690484.95.0.111987955887.issue26195@psf.upfronthosting.co.za>
2016-01-25 02:54:44alex_python_orglinkissue26195 messages
2016-01-25 02:54:42alex_python_orgcreate