I came across this interesting statement in "Caveats" section of the documentation for the thread
module today:
Not all built-in functions that may block waiting for I/O allow other threads to run. (The most popular ones (
time.sleep()
,file.read()
,select.select()
) work as expected.)
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.
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.