本文介绍了是否有阻止I/O的内置函数不允许其他线程运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 今天的模块:

在我见过的所有其他讨论过的Python线程的几乎所有其他地方,始终存在这样的假设:所有执行I/O的内置函数都将释放GIL,这意味着其他线程可以在该函数阻塞时运行.据我所知,一个I/O操作阻塞其他线程的唯一风险是,如果它是由于错误的C扩展而被忽略的,那么它就不会释放GIL.

Pretty much everywhere else I've ever seen Python threads discussed, there has always been an assumption that all built-in functions which do I/O will release the GIL, meaning other threads can run while the function blocks. As far as I knew, the only risk of an I/O operation blocking other threads would be if it was being made to a buggy C-extension that neglected to release the GIL.

那么,thread文档中的这一说法是否正确?是否有任何内置的,阻止不释放GIL的I/O操作?到目前为止,我还没有找到任何具体的例子.

So, is this statement from the thread docs actually true? Are there any built-in, blocking I/O operations that don't release the GIL? I haven't been able to find any specific examples thus far.

推荐答案

这是来自Guido van Rossum的官方词这个:

Here's the official word from Guido van Rossum on this one:

所以我的问题的答案是否".

So the answer to my question is "No".

这篇关于是否有阻止I/O的内置函数不允许其他线程运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 02:20