Python PyInstaller与多处理

Python PyInstaller与多处理,python,wxpython,pyinstaller,Python,Wxpython,Pyinstaller,我想从带有多处理模块的GUI(wxPython)启动一个简单的HTTP服务器 如果我直接用Python启动它,这段代码可以很好地工作。但是在内置版本(使用PyInstaller 2或3)中,如果我启动多道程序->而不是运行函数中的代码,整个应用程序,GUI将再次启动。 有人知道为什么吗 #!/usr/bin/env python # -*- coding: UTF-8 -*- import wx, sys, time, thread, datetime, os, platform, multi

我想从带有多处理模块的GUI(wxPython)启动一个简单的HTTP服务器

如果我直接用Python启动它,这段代码可以很好地工作。但是在内置版本(使用PyInstaller 2或3)中,如果我启动多道程序->而不是运行函数中的代码,整个应用程序,GUI将再次启动。 有人知道为什么吗

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import wx, sys, time, thread, datetime, os, platform, multiprocessing, socket
import favicon
from genLicense import load as loadLicense
from licenseDetailDialog import Dialog as licenseDetailDialog

class mp(multiprocessing.Process):
    def __init__(self, queue, func, *args):
        multiprocessing.Process.__init__(self)
        self.queue = queue
        self.func = func
        self.args = args
    def run(self):
        time.sleep(0.1)
        try:
            self.func(*self.args)
        except Exception as e:
            self.queue.put(e)
            print(e)

class MainFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        kwds["style"] = wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER
        wx.Frame.__init__(self, *args, **kwds)

        # [...]

        self.button_startstop = wx.Button(self, wx.ID_ANY, _("Server &starten"))

        # [...]

    def startstop(self, event):
        if self.running:
            self._stop()
        else:
            self._start()

    def _start(self):
        print("Starting...")

        try:
            port = 123
            queue = multiprocessing.Queue()

            self.server_process = mp(queue, ACC_main.START, port)
            self.server_process.start()
            print("\tPID: {}\n\n{}".format(self.server_process.pid, "="*50))

            # [...]

            self.running = True

        except:
            # [...]


    def _stop(self):
        print("\n{}\nStopping...".format("="*50))

        if self.running:
            print("\tPID: {}\n".format(self.server_process.pid))
            self.server_process.terminate()
        self.running = False

在创建窗口之前,在代码中添加行
multiprocessing.freeze\u support()
。记录在案