Python BOT keeps disconnecting, even with PONGs

the part that’s bugging me is recv(1024) since it blocks UNTIL it receives 1024 bytes. Now what if it receives less?
It will wait, and not respond to the PING that might’ve happened. This is why I’m shocked by the fact that the socket library doesn’t provide a readline method.