问题描述
我是桌面程序员,但我想了解一些有关 Web 服务的知识.我决定使用python.我正在尝试了解 Web 应用程序的工作原理.我知道如何创建基本的龙卷风网站(请求 - 响应)和工作 jabber 客户端,但我不知道如何混合它们.我可以在 Web 服务中使用任何 python 组件吗?它们是否必须具有特定的结构(同步或异步)?因为我被困在循环处理程序中:
I am desktop programmer but I want to learn something about web services. I decided for python. I am trying understand how web applications works. I know how to create basic tornado website (request - response) and working jabber client, but I don't know how to mix them. Can I use any python components in web services? Does they must have specific structure ( sync or async )? Because I'm stuck in loop handlers:
如果 tornado 通过命令启动 web 服务器:
If tornado start web serwer by command:
app = Application()
app.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
...那么我如何(从哪里)开始 xmpp 循环?
... so how (where) can I start xmpp loop?
client.connect()
client.run()
我认为 tornado 监听循环应该处理 xmpp 监听,但不知道如何
I think that tornado listen loop should handle xmpp listening, but don't know how
问候.
我忘了.我正在使用 pyxmpp2
I forgot. I am using pyxmpp2
推荐答案
我相信你想要完成的事情在一个 python 线程中是不可行的,因为两者都试图同时监听,而这在一个线程中是不可能的线.我是否建议您查看 this 关于线程的教程.
I believe what you are trying to accomplish is not feasible in one thread of python as both are trying to listen at the same time which isn't possible in one thread. Might I suggest looking at this tutorial on threading.
另一个问题是你是想制作一个基于 web 的 xmpp 还是只有一个 xmpp &html 服务器在同一脚本中运行.如果您想尝试前者,我建议您使用 zeromq 或 研究线程间通信href="http://docs.python.org/library/queue.html" rel="nofollow">队列
Another question would be are you trying to make a web based xmpp or just have a xmpp & html server running in the same script. If you wish to try the former I would advise you to look into inter-thread communication either with zeromq or queue
这篇关于龙卷风 Web 应用程序中的 Python xmpp jabber 客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!