title: Python client keeps websocket open and reacts to received messages
body: <p>I'm trying to implement a REST client in python that reacts to messages received from the server received through an opened websocket with the concerned server.
  Here is the scenario:</p>
  
  <ul>
  <li>client opens a websocket with the server </li>
  <li>from time to time, the server sends a message to the client</li>
  <li>when the client receives the messages, it gets some information from
  the server</li>
  </ul>
  
  <p>The current client I have is able to open the websocket and to receive the message from the server. However, as soon as it receives the messages, it gets the information from the server then terminates while I'd like to keep it listening for other messages that will make it get a new content from the server.</p>
  
  <p>Here is the piece of code I have:</p>
  
  <pre><code>def openWs(serverIp, serverPort):
      ##ws url setting
      wsUrl = "ws://"+serverIp+":"+serverPort+"/websocket"
  
      ##open ws
      ws = create_connection(wsUrl)
  
      ##send user id
      print "Sending User ID..."
      ws.send("user_1")
      print "Sent"
  
      ##receiving data on ws
      print "Receiving..."
      result =  ws.recv()
  
      ##getting new content
      getUrl = "http://"+serverIp+":"+serverPort+"/"+result+"/entries"
      getRest(getUrl)
  </code></pre>
  
  <p>I don't know if using threads is appropriate or not, I'm not expert in that.
  If someone could help, it'll be great.</p>
  
  <p>Thanks in advance.</p>