I
I
Ilya Kaznacheev2014-08-11 23:33:36
Python
Ilya Kaznacheev, 2014-08-11 23:33:36

Why is there an error on GET request in python?

I make several requests in a loop that contains a list of GET request attributes.
More or less like this:

class...
    self.log_paths = ["a=123","b=456","c=789"]
    def main_loop(self)
        self.basepath = "index.html?"
        self.httpServ = httplib.HTTPConnection(self.host, self.port)
        self.httpServ.connect()

            for item in self.log_paths:
                main_path = self.basepath + item
                self.run_removed(self.httpServ, main_path)
                time.sleep(0.5)

    def run_removed(self, serv, path):
        serv.request('GET', path)
        response = serv.getresponse()
        return

The first iteration works, and on the second it displays an error:
Failed (<class 'httplib.ResponseNotReady'>)
In theory, at each iteration, the response variable is declared anew, and there should not be a conflict.
So what's the problem then?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey K, 2014-08-12
@Color

For each request, a separate connection must be created.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question