简体   繁体   English

带有Twisted或Node.js的Python

[英]Python with Twisted, or Node.js

I am working on a project which is I/O bound. 我正在一个受I / O约束的项目。

I have 3 dependent tasks: 我有3个相关任务:
1. scraping a site + extracting the main content(removing comments/ads etc) 1.抓取网站+提取主要内容(删除评论/广告等)
2. as soon as 1 completes it sends the data to a summerizer 2. 1完成后,它将数据发送给求和器
3. as soon as 2 completes it calls a view and renders a page 3. 2完成后,它将调用视图并呈现页面

I know Python and Django at the moment. 我目前知道Python和Django。 What technologies do you recommend me for this project? 您为这个项目向我推荐什么技术? (I know that Python + Twisted or node.js are ideal for I/O bound projects). (我知道Python + Twisted或node.js是I / O绑定项目的理想选择)。

If you're already using Python, you're probably better off sticking with a Python library, especially when there are so many powerful asynchronous Python libraries. 如果您已经在使用Python,那么最好还是坚持使用Python库,尤其是在有这么多强大的异步Python库的情况下。 Node.js is fine, but switching between Python and Javascript is unnecessary. Node.js很好,但是不需要在Python和Javascript之间切换。

Anyway, your question is very very vague. 无论如何,您的问题非常模糊。 You can absolutely use Twisted and it will probably do what you want just fine, as long as you learn the API well enough. 您可以绝对使用Twisted,只要您对API有足够的了解,它就可以满足您的要求。 Other asynchronous frameworks include gevent and a web server called Tornado . 其他异步框架包括gevent和称为Tornado的Web服务器。

There's also Celery which is used specifically for asynchronous processing of queues. 还有Celery ,它专门用于队列的异步处理。 It may or may not be helpful to what you want. 它可能对您想要的没有帮助。

I recommend you do a lot of research, look at the documentation of the above libraries, and decide what'll fit your project best. 我建议您进行大量研究,查看上述库的文档,然后确定最适合您的项目的项目。 If you have more specific questions you can ask the respective IRC channels of the library, or post a clearer question here. 如果您有更具体的问题,则可以询问库的各个IRC通道,或在此处发布更清晰的问题。

I am finally using django-socketio. 我终于在使用django-socketio。

https://github.com/stephenmcd/django-socketio https://github.com/stephenmcd/django-socketio

In case websockets are not supported, socketio falls back to long polling. 如果不支持WebSocket,则socketio会退回到长时间轮询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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