I am working on a client for a web service using pycurl. The client opens a connection to the streaming service and creates it in a separate stream. Here the version of the connection configuration is trimmed:
def _setup_connection(self): self.conn = pycurl.Curl() self.conn.setopt(pycurl.URL, FILTER_URL) self.conn.setopt(pycurl.POST, 1) . . . self.conn.setopt(pycurl.HTTPHEADER, headers_list) self.conn.setopt(pycurl.WRITEFUNCTION, self.local_callback) def up(self): if self.conn is None: self._setup_connection() self.perform()
Now that I want to close the connection, if I call
self.conn.close()
I get the following exception:
error: cannot invoke close() - perform() is currently running
Which, in a sense, makes sense, the connection is constantly open. I hunted around and could not find a way around this problem and completely close the connection.
source share