[英]Python Signals between threads
I created a UDP socket server 我创建了一个UDP套接字服务器
self.UDPServer = SocketServer.UDPServer( ( UDP_IP, UDP_PORT ), UDPServerHandler )
self.server_thread = threading.Thread( target = self.UDPServer.serve_forever )
self.server_thread.setDaemon( True )
self.server_thread.start()
And this is my UDP handler 这是我的UDP处理程序
class UDPServerHandler( SocketServer.BaseRequestHandler ):
def handle( self ):
recv = '';
try:
ans = self.request[0]
print "received" + ans
if( ans ):
#recv = self.checkMessage( recv + ans );
print( ans )
except:
pass;
My question is, how can I send the received data to an other thread? 我的问题是,如何将接收到的数据发送到另一个线程? For example I have a GUI, and I want to display the received massage in a text box, or work on the received data etc..
例如,我有一个GUI,我想在文本框中显示接收到的消息,或处理接收到的数据等。
一种简单的方法是使用队列模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.