title: Check if data available in sockets in python
body: <p>I want a functionality to check if data is waiting in the socket to be read before reading it. Something like this would be helpful:</p>
  
  <pre><code>if (data available) then read data
  
  else wait in blocking mode till data becomes available
  </code></pre>
  
  <p>How can I achieve this in Python</p>