def _request(self, url, method='GET', params=None):
        """Internal stream request handling"""
        self.connected = True
        retry_counter = 0

        method = method.lower()
        func = getattr(self.client, method)

        def _send(retry_counter):
            while self.connected:
                try:
                    if method == 'get':
                        response = func(url, params=params, timeout=self.timeout)
                    else:
                        response = func(url, data=params, timeout=self.timeout)
                except requests.exceptions.Timeout:
                    self.on_timeout()
                else:
                    if response.status_code != 200:
                        self.on_error(response.status_code, response.content)

                    if self.retry_count and (self.retry_count - retry_counter) > 0:
                        time.sleep(self.retry_in)
                        retry_counter += 1
                        _send(retry_counter)

                    return response

        while self.connected:
            response = _send(retry_counter)

            for line in response.iter_lines():
                if not self.connected:
                    break
                if line:
                    try:
                        if not is_py3:
                            self.on_success(json.loads(line))
                        else:
                            line = line.decode('utf-8')
                            self.on_success(json.loads(line))
                    except ValueError:
                        self.on_error(response.status_code, 'Unable to decode response, not vaild JSON.')

        response.close()
dataset/ETHPy150Open splunk/splunk-app-twitter/twitter2/bin/twython/streaming/api.py/TwythonStreamer._request/original