title: Python: Why does this non-blocking call to recv block?
body: <p>I have the following code in the $<strong>init</strong> call of a thread:</p>
  
  <pre><code>self.conn = copy.deepcopy(conn)
  self.conn.setblocking(0)
  </code></pre>
  
  <p>conn is a socket and is passed as an argument to $<strong>init</strong>
  Every thread recieves a unique socket. In the run method I have:</p>
  
  <pre><code>self.running = True
  self.conn.send("Connected")
  print self.name, "has a timeout of", self.conn.gettimeout()
  
  while self.running:
      try:
          now = self.conn.recv(8192)
          print "Recieved:", now, "\n\tFrom:", self.name
          self.process(now)
      except socket.error:
           raise
  
       print "hi from", self.name
       time.sleep(1)
  </code></pre>
  
  <p>The timeout is printed as 0.0, but "hi from threadname" only printed out when a message is recieved and the exception is never raised! It looks as if the recv method blocks, but why would it do that?</p>