Python中multiprocessing与concurrent相比为什么差距这么大?
高洛峰
高洛峰 2017-04-18 10:10:22
0
2
800

好吧,我弄错了,concurrent与multiprocessing与只有在处理IO型任务的时候才有优势,计算型任务没有什么不同。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
伊谢尔伦

Are you sure the code is correct? Why do you feel that multiprocess calculates it twice...

洪涛

Multi-process is among multiple processes, the blocking of one process will not affect other processes. For example, performing a large number of calculation operations in one process will not have a major impact on other processes.

Coroutine is in a thread. If one task in the coroutine is blocked, other tasks will also be affected. For example, if a large number of calculation operations are performed in a task, this task will block other tasks.

So coroutines are not suitable for processing computing-intensive tasks, but are suitable for processing IO-intensive tasks. Because Ctrip cooperates with asynchronous IO, you can get the pleasure of synchronous programming without blocking the process.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template