What I'm trying to do is have an object (this is a gstreamer process that runs in a separate thread) to be able to call the write_message () function on WebSocketHandler
Here is the code snippet that I currently have
app = tornado.web.Application([
(r'/', RadioSocketHandler),
])
class RadioSocketHandler(tornado.websocket.WebSocketHandler):
def initialize(self):
self.player = MusicPlayer(self)
thread.start_new(self.player.start(), ())
class MusicPlayer(object):
websocket_handler = None
def __init__(self, sockethandler):
self.websocket_handler = sockethandler
self.websocket_handler.write_message("success")
However, this will not work. "initialize" is never called. What am I doing wrong?
__init__()
doesn't work either. Or is there another way to call a function from RadioSocketHandler outside of its own class? I'm new to Python fyi
source
share