Python xmpp jabber client in tornado web application

I am a computer programmer, but I want to learn something about web services. I decided to use python. I am trying to understand how web applications work. I know how to create a basic tornado website (request-response) and a working jabber client, but I do not know how to mix them. Can i use any python components in web services? Should they have a specific structure (synchronization or asynchronous)? Because I am stuck in loop handlers:

If the tornado starts the web server with the command:

app = Application()
app.listen(options.port)
tornado.ioloop.IOLoop.instance().start()

... since (where) can I start the xmpp loop?

client.connect()
client.run()

I think the tornado listening loop should handle xmpp listening, but don't know how

Sincerely.

Edit: I forgot. I am using pyxmpp2

+2
2

, , , python, , . .

: -xmpp xmpp html-, script. , zeromq, queue

0

, WebSocketHandler Thread .

class BotThread(threading.Thread):

    def __init__(self,my_jid,settings,on_message):
        super(BotThread,self).__init__()
        #EchoBot is pyxmpp2 Client
        self.bot = EchoBot(my_jid, settings,on_message= on_message)

    def run(self):
        self.bot.run()


class ChatSocketHandler(tornado.websocket.WebSocketHandler):
    def open(self): 
        #init xmpp client
        my_jid = 
        settings = 
        bot =BotThread(my_jid, settings,on_message=self.on_message)
        bot.start()

0

Source: https://habr.com/ru/post/1724744/


All Articles