We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e10f51 commit 0c00697Copy full SHA for 0c00697
pulsar/client/transport/curl.py
@@ -1,3 +1,4 @@
1
+import contextlib
2
import io
3
import logging
4
import os.path
@@ -70,16 +71,13 @@ def post_file(url, path):
70
71
# wrap it in a better one.
72
message = NO_SUCH_FILE_MESSAGE % (path, url)
73
raise Exception(message)
- try:
74
- c = _new_curl_object_for_url(url)
+ with contextlib.closing(_new_curl_object_for_url(url)) as c:
75
c.setopt(c.HTTPPOST, [("file", (c.FORM_FILE, path.encode('ascii')))])
76
c.perform()
77
status_code = c.getinfo(HTTP_CODE)
78
if int(status_code) != 200:
79
message = POST_FAILED_MESSAGE % (url, status_code)
80
81
- finally:
82
- c.close()
83
84
85
def get_size(url) -> int:
0 commit comments