After watching videos about GIL I want to make short explanation why presented code works in very slow way.
Python threads are real system pthreads(I thought that scheduler is implemented in python previously). Anyway it does not allow to execute code on multi core systems, due to GIL. Thread to execute code must get GIL mutex. Other threads must wait to release. Therefore, there is no parallelism, threads execute code one after another, even on multi core system.(reason is that it was designed in 1990 when single core computers were used)
Situation when thread releases mutex are triggered by IO access, for example usage of sockets, filesystem functions, sleep. There is also second option, GIL is released by default every 5ms in python3. In python 2.7 it was done every 100 instructions.
In my code, one thread have empty while loop which is CPU bounded and main thread is IO bounded because it gets information about sockets. Theoretically with things that I mentioned, my code should work. Thread with while loop should release GIL every 5ms and main IO thread should execute. In reality this doesn't work in that way. This is associated with specific GIL lock implementation(IO thread at first releases GIL when it get GIL) what causes that mainly CPU bound thread is executed. Details are explained in mentioned videos.
Adding sleep inside while loop solves problem because sleeping thread can not immediately be executed by Linux scheduler,even when IO thread releases GIL firstly, It immediately gets GIL mutex(there is no other active CPU bound thread) and can execute their own code.
In any of my dreams and my imaginations I would not discover presented code relations without mentioned videos.