code: async def _upgrade_websocket(self, environ):
          
          if self.upgraded:
              raise IOError('Socket has been upgraded already')
          if self.server._async['websocket'] is None:
              # the selected async mode does not support websocket
              return self.server._bad_request()
          ws = self.server._async['websocket'](self._websocket_handler)
          return await ws(environ)
docs: Upgrade the connection from polling to websocket.