Python中的SimpleQueue与Queue-使用SimpleQueue有什么优势? [英] SimpleQueue vs Queue in Python - what is the advantage of using SimpleQueue?

查看:1065
本文介绍了Python中的SimpleQueue与Queue-使用SimpleQueue有什么优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

队列-同步队列类只是声明


SimpleQueue允许的功能较少。

there are fewer functions allowed with SimpleQueue.

对于多线程应用程序,我需要非常基本的队列功能,使用SimpleQueue是否有任何帮助?

I need very basic queue functionality for a multithreading application, would it help in any way to use SimpleQueue?

推荐答案

queue.SimpleQueue 处理的不仅仅是线程安全的并发。它处理 reentrancy -在不稳定的情况下调用 queue.SimpleQueue.put 是安全的,因为它可能会中断同一线程中的其他工作。例如,您可以从 __ del __ 方法,弱引用回调或 signal 模块信号处理程序。

queue.SimpleQueue handles more than threadsafe concurrency. It handles reentrancy - it is safe to call queue.SimpleQueue.put in precarious situations where it might be interrupting other work in the same thread. For example, you can safely call it from __del__ methods, weakref callbacks, or signal module signal handlers.

如果需要,请使用 queue.SimpleQueue

这篇关于Python中的SimpleQueue与Queue-使用SimpleQueue有什么优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆