简体   繁体   中英

Python Signals between threads

I created a UDP socket server

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

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..

一种简单的方法是使用队列模块。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM