Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always close pycurl instance #366

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions pulsar/client/transport/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def execute(self, url, method=None, data=None, input_path=None, output_path=None
if not output_path:
return buf.getvalue()
finally:
c.close()
buf.close()


Expand All @@ -69,13 +70,16 @@ def post_file(url, path):
# wrap it in a better one.
message = NO_SUCH_FILE_MESSAGE % (path, url)
raise Exception(message)
c = _new_curl_object_for_url(url)
c.setopt(c.HTTPPOST, [("file", (c.FORM_FILE, path.encode('ascii')))])
c.perform()
status_code = c.getinfo(HTTP_CODE)
if int(status_code) != 200:
message = POST_FAILED_MESSAGE % (url, status_code)
raise Exception(message)
try:
c = _new_curl_object_for_url(url)
c.setopt(c.HTTPPOST, [("file", (c.FORM_FILE, path.encode('ascii')))])
c.perform()
status_code = c.getinfo(HTTP_CODE)
if int(status_code) != 200:
message = POST_FAILED_MESSAGE % (url, status_code)
raise Exception(message)
finally:
c.close()
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved


def get_size(url) -> int:
Expand Down Expand Up @@ -122,6 +126,7 @@ def get_file(url, path: str):
message = GET_FAILED_MESSAGE % (url, status_code)
raise Exception(message)
finally:
c.close()
buf.close()


Expand Down
Loading