Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
线程wxPython和XMLRPC_Python_Multithreading_Wxpython_Xml Rpc - Fatal编程技术网

线程wxPython和XMLRPC

线程wxPython和XMLRPC,python,multithreading,wxpython,xml-rpc,Python,Multithreading,Wxpython,Xml Rpc,我正在使用wxPython和XMLRPC执行一个应用程序,我需要每次XMLRPC服务器有请求时窗口都执行一个操作 我怎么能不堵住主窗口呢 我尝试使用线程,但它不起作用。我还尝试在框架的构造函数中调用线程的run方法,但都不起作用 对不起,我说的是这样的话 我希望澄清 谢谢这里有一个使用SimpleXMLRPCServer的线程化XMLRPC服务器的示例。请注意wx.CallAfter以调用wx主线程和“返回0”(尽管您可以配置服务器,以便返回值None是可以的) 下面是一个使用SimpleXML

我正在使用wxPython和XMLRPC执行一个应用程序,我需要每次XMLRPC服务器有请求时窗口都执行一个操作

我怎么能不堵住主窗口呢

我尝试使用线程,但它不起作用。我还尝试在框架的构造函数中调用线程的run方法,但都不起作用

对不起,我说的是这样的话 我希望澄清
谢谢这里有一个使用SimpleXMLRPCServer的线程化XMLRPC服务器的示例。请注意wx.CallAfter以调用wx主线程和“返回0”(尽管您可以配置服务器,以便返回值None是可以的)


下面是一个使用SimpleXMLRPCServer的线程化XMLRPC服务器的示例。请注意wx.CallAfter以调用wx主线程和“返回0”(尽管您可以配置服务器,以便返回值None是可以的)


你能给我们看看你的密码吗?还有,你说它不工作是什么意思?你有没有得到异常、回溯、故障?如果您可以发布您获得的实际结果,这将有所帮助。您可以启动一个新线程来处理新请求,只要记住在尝试从新线程更新GUI时使用
wx.CallAfter
。您可以向我们展示您的代码吗?还有,你说它不工作是什么意思?你有没有得到异常、回溯、故障?如果您可以发布您得到的实际结果,这会有所帮助。您可以启动一个新线程来处理新请求,只要记住在尝试从新线程更新GUI时使用
wx.CallAfter
from SimpleXMLRPCServer import SimpleXMLRPCServer
import threading

class XMLRPCServerThread(threading.Thread):
    def __init__(self, remoteObject, host='localhost', port=8000):
        self.remoteObject = remoteObject
        self.host = host
        self.port = port
        threading.Thread.__init__(self)

    def stop(self):
        self.server.shutdown()    

    def run(self):
        self.server = SimpleXMLRPCServer( (self.host, self.port), logRequests=False )
        self.server.register_instance( self.remoteObject )
        self.server.serve_forever()

class MyRemoteCalls(object):

    def __init__(self, obj):
        self.obj = obj

    def exampleCall(self, arg):
        wx.CallAfter(self.obj.method, arg)
        return 0  

def getRPCThread(obj, host='localhost', port=8000):
    remoteObj = MyRemoteCalls(obj)
    rpcThread = XMLRPCServerThread(remoteObj, host, port)
    rpcThread.start()
    return rpcThread