Brian píše v Po 10. 10. 2011 v 16:11 -0700:
> Martin, are you saying that you've tested it on XP and it experiences
> an error in activating the context? Is the error meaningful or is it
> something that can be ignored?
> 
> 
> On Oct 10, 5:50 pm, Martin Zibricky <[email protected]> wrote:
> > Brian píše v Po 10. 10. 2011 v 14:17 -0700:
> >
> > > os.path.dirname(os.path.abspath(__file__))
> >
> > os.path.dirname(os.path.abspath(sys.executable)) could also work. 

I tried to set _MEIPASS2 to
os.path.dirname(os.path.abspath(sys.executable)) and it seems to work
correctly.

Attached is the multiprocess code that works for me on winxp without any
context error. Could you test it please?

If it works we should create from this example a test case for
pyinstaller.


Output when running on winxp:
--------------------------------------------------
Z:\tmp\pyi_trunk>.\test_multiprocess_2_2\dist\test_multiprocess_2_2
\test_multiprocess_2_2.exe
_MEIPASS2 is NULL
Extracting binaries
Executing self as child with Setting up to run child
Creating child process
Waiting for child process to finish...
_MEIPASS2 is Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist
\test_multiprocess_2_2\
Already in the child - running!
manifestpath: Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist
\test_multiprocess_2_2\
test_multiprocess_2_2.exe.manifest
Activation context created
Activation context activated
Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist\test_multiprocess_2_2
\python27.dll
Manipulating evironment
PYTHONPATH=Z:/tmp/pyi_trunk/test_multiprocess_2_2/dist/test_multiprocess_2_2
importing modules from CArchive
extracted iu
extracted struct
extracted archive
Installing import hooks
outPYZ1.pyz
Running scripts
pyb
pyb
OK.
Deactivating activation context
Releasing activation context
Done
Back to parent...
Freeing status for Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist
\test_multiprocess
_2_2\test_multiprocess_2_2.exe

Z:\tmp\pyi_trunk>_MEIPASS2 is Z:\tmp\pyi_trunk\test_multiprocess_2_2
\dist\test_m
ultiprocess_2_2\
Already in the child - running!
manifestpath: Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist
\test_multiprocess_2_2\
test_multiprocess_2_2.exe.manifest
Activation context created
Activation context activated
Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist\test_multiprocess_2_2
\python27.dll
Manipulating evironment
PYTHONPATH=Z:/tmp/pyi_trunk/test_multiprocess_2_2/dist/test_multiprocess_2_2
importing modules from CArchive
extracted iu
extracted struct
extracted archive
Installing import hooks
outPYZ1.pyz
Running scripts
SendeventProcess
SendeventProcess

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.

import multiprocessing.forking
import sys
import os

class _Popen(multiprocessing.forking.Popen):
    def __init__(self, *args, **kw):
        if hasattr(sys, 'frozen'):
            os.putenv('_MEIPASS2',
                os.path.dirname(os.path.abspath(sys.executable)) + os.sep)
        try:
            super(_Popen, self).__init__(*args, **kw)
        finally:
            if hasattr(sys, 'frozen'):
                os.unsetenv('_MEIPASS2')

class Process(multiprocessing.Process):
    _Popen = _Popen

class SendeventProcess(Process):
    def __init__(self, resultQueue):
        self.resultQueue = resultQueue

        multiprocessing.Process.__init__(self)
        self.start()

    def run(self):
        print 'SendeventProcess'
        self.resultQueue.put((1, 2))
        print 'SendeventProcess'


if __name__ == '__main__':
    multiprocessing.freeze_support()
    print 'pyb'
    resultQueue = multiprocessing.Queue()
    SendeventProcess(resultQueue)
    print 'pyb'

Reply via email to