code: def finish_response(self):
          
          # force execution of the result iterator until first actual content
          rest = iter(self.result)
          first = list(itertools.islice(rest, 1))
          self.result = itertools.chain(first, rest)
          # now it's safe to look if environ was modified
          ws = None
          if self.environ:
              self.environ.pop('ws4py.socket', None)
              ws = self.environ.pop('ws4py.websocket', None)
  
          try:
              SimpleHandler.finish_response(self)
          except:
              if ws:
                  ws.close(1011, reason='Something broke')
              raise
          else:
              if ws:
                  self.request_handler.server.link_websocket_to_server(ws)
docs: Completes the response and performs the following tasks:
  
          - Remove the `'ws4py.socket'` and `'ws4py.websocket'`
            environ keys.
          - Attach the returned websocket, if any, to the WSGI server
            using its ``link_websocket_to_server`` method.