[英]Twisted with queue for CPU-bound tasks
I have an HTTP server which does some IO stuff, then does some CPU-bound stuff (PIL) and then replies with data (magnitude of megabyte or so). 我有一个HTTP服务器,它做一些IO的东西,然后做一些CPU绑定的东西(PIL),然后回复数据(兆字节大小左右)。
(a) My first idea is something like this: a process for server and IO, based on Twisted, and several processes for PIL stuff, with queue. (a)我的第一个想法是这样的:服务器和IO的过程,基于Twisted,以及PIL的几个进程,带队列。
If this architecture is reasonable, then there probably is a library which does exactly that: multiprocess queue for Twisted. 如果这种架构是合理的,那么可能存在一个完全相同的库:Twisted的多进程队列。 However, I'm not really experienced in Twisted and know nothing of its community so the only thing I found is ampoule
, for which I found neither docs nor description which would persuade me that it's the right tool for a job. 然而,我在Twisted中并没有真正的经验,对它的社区一无所知,所以我发现的唯一的东西就是ampoule
,我找不到任何文件或说明,这些都不能说服我这是一个适合工作的工具。
(b) Another idea is to just run several servers in several threads, with both IO and CPU stuff going in each on of them. (b)另一个想法是在几个线程中运行多个服务器,每个服务器上都有IO和CPU内容。 This seems stupid because CPU stuff will block, but maybe I'm not really understanding it. 这看起来很愚蠢,因为CPU的东西会阻塞,但也许我真的不理解它。
So, questions: 所以,问题:
Twisted
+ ampoule
or what?) 你会如何实现它(使用Twisted
+ ampoule
或什么?)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.