Reputation: 73
I have a thread in python which handled receive OSC packets... I need to retrieve datas from osc in my main function. How could get data from thread out of the thread ? Here's the code to demonstrate my issue:
import OSC
import threading
import atexit
#------OSC Server-------------------------------------#
receive_address = '127.0.0.1', 7402
# OSC Server. there are three different types of server.
s = OSC.ThreadingOSCServer(receive_address)
# this registers a 'default' handler (for unmatched messages)
s.addDefaultHandlers()
class receive:
def printing_handler(addr, tags, data, source):
if addr=='/data':
self.data=data.pop(0)
s.addMsgHandler("/data", printing_handler)
return data
def main(self):
# Start OSCServer
#Main function...I need to retrieve 'data' from the OSC THREAD here
print "Starting OSCServer"
st = threading.Thread(target=s.serve_forever)
st.start()
reception=receive()
reception.main()
plouf = data.reception()
print plouf
thanks in advance
Upvotes: 0
Views: 977
Reputation: 645
Use a Queue
from the standard library, or use Global variables.
Upvotes: 1