code: def receive(self):
          
          try:
              itr = 0
              while self.connected:
                  
                  r, w, e = select.select(
                      (self.sock, ), (), (), 10.0)
                  
                  if r:
                      message = json.loads(self.recv())
                      
                      if 'fetch' in message:
                          self.fetch_id = message['fetch']
                      
                      if 'failure' in message:
                          raise InvalidFetch(message['failure'])
                      
                      if 'records' in message:
                          if 'added' in message['records']:
                              num = len(message['records']['added'])
                          else:
                              num = len(message['records'])
                          
                          logger.debug('Query returned %s records.', num)
                          if self.max_recv:
                              itr += 1
                          
                      if 'end' in message:
                          logger.debug('Received end message: %s' % message['end'])
                          yield message
                          break
                      
                      yield message
                      if self.max_recv and self.max_recv <= itr:
                          break   
  
          except (Exception, KeyboardInterrupt, SystemExit, FetchAborted) as e:
              logger.info('Caught exception in receive: %s -> %s', type(e), str(e))
              if isinstance(e, (SystemExit, InvalidFetch)):
                  # propagate SystemExit, InvalidFetch
                  raise
          finally:
              if self.connected:
                  if self.fetch_id:
                      self.send(json.dumps({'abort': self.fetch_id}))
                  self.close()
              
              if self.thread:
                  self.event.set()
                  while self.thread.isAlive():
                      self.event.wait(1)
              
              logger.info('Closed web socket connection normally.')
docs: Generator yielding results from the web socket. Results
          will come as they are received. Even though socket select
          has a timeout, the SMC will not reply with a message more
          than every two minutes.