简体   繁体   English

为什么multiprocessing.Queue没有task_done方法

[英]Why does multiprocessing.Queue have no task_done method

为什么Queue.Queuetask_done方法而multiprocessing.Queue没有这种方法?

我认为您需要JoinableQueue

My guess would be: multithreading module was implemented very early, multiprocessing module came in 2.6 version. 我的猜测是: multithreading模块是在很早以前实现的, multiprocessing模块是2.6版。

The queue design was slightly corrected for multiprocessing and offers better flexibility than the multithreading , because you can choose between Queue , SimpleQueue and JoinableQueue depending on your use cases (speed vs reliability). 队列设计已针对multiprocessing进行了稍微校正,并且比multithreading提供了更好的灵活性,因为您可以根据用例(速度与可靠性)在QueueSimpleQueueJoinableQueue之间进行选择。

Now modifing multithreading like this would have caused backwards incompatibility, since join and task_done methods would have to be removed. 现在像这样修改multithreading将导致向后不兼容,因为必须删除jointask_done方法。 Imagine the code needed to be refactored, new tests had to be written, API broken - for me clearly no benefits. 想象一下需要重构的代码,必须编写新的测试,破坏API,对我来说显然没有任何好处。

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

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