you and atagar...
I am atagar.
atagar's timeout was way too short in my testing.
I picked 20 ms because that's the runtime for fast queries, like 'GETINFO version'. There was a tradeoff in picking the timeout duration, but since it was within a loop it didn't impact correctness. Lowering meant more work (looping rather than sleeping on input) and higher meant a raised shutdown time.
This said, a later change to shut down the socket unblocked the recv call when closing, so this timeout was removed.
I have found similar problems and I would like to solve this issue.
All the concurrency issues for shutting down should have been addressed. What sort of problems are you encountering? Do you have a use case for reproducing the issue?
I would like to have readline() detect when a socket error has occurred.
A socket error should result in a None return value that shuts down _thread.
Cheers! -Damian