code: def on_open(self):
          
          def event_loop():
              logger.debug(pformat(self.query.request))
              self.send(json.dumps(self.query.request))
              while not self.event.is_set():
                  #print('Waiting around on the socket: %s' % self.gettimeout())
                  self.event.wait(self.gettimeout())
                  
              logger.debug('Event loop terminating.')
      
          self.thread = threading.Thread(
              target=event_loop)
          self.thread.setDaemon(True)
          self.thread.start()
docs: Once the connection is made, start the query off and
          start an event loop to wait for a signal to
          stop. Results are yielded within receive().