In cPython (the default Python implementation), how often does thread switching happen? It is not a matter of using multiple cores; I know about GIL and understand that at the moment only one thread will be started.
I have seen several cases where I have two log messages in sequence, and the first log message will be emitted, but the second will not be emitted in a few seconds. This is probably because Python decided to switch threads between the two log statements. This makes me think that Python switches between threads once every couple of seconds, which is much slower than I expected. Is it correct?
source
share