mirror of
https://opendev.org/x/pyghmi
synced 2025-01-14 19:57:47 +00:00
Make the webclient primitives a bit more resilient
The underlying class state machine can get hairy if things race with each other. Transparently create independent instances to have dedicated state machines for transactions. Change-Id: I17616a437374f6dfdcd46d459cfc7ed00405b311
This commit is contained in:
parent
87cc663751
commit
f4ece6cd42
@ -622,7 +622,7 @@ class XCCClient(IMMClient):
|
||||
if rsv['return'] != 0:
|
||||
raise Exception('Unexpected return to reservation: ' + repr(rsv))
|
||||
xid = random.randint(0, 1000000000)
|
||||
uploadthread = FileUploader(self.wc.dupe(),
|
||||
uploadthread = FileUploader(self.wc,
|
||||
'/upload?X-Progress-ID={0}'.format(xid),
|
||||
filename, data)
|
||||
uploadthread.start()
|
||||
|
@ -75,8 +75,8 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
self.cert_reqs = ssl.CERT_NONE # verification will be done ssh style..
|
||||
if clone:
|
||||
self._certverify = clone._certverify
|
||||
self.cookies = clone.cookies.copy()
|
||||
self.stdheaders = clone.stdheaders.copy()
|
||||
self.cookies = clone.cookies
|
||||
self.stdheaders = clone.stdheaders
|
||||
else:
|
||||
self._certverify = verifycallback
|
||||
self.cookies = {}
|
||||
@ -113,11 +113,12 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
return rsp
|
||||
|
||||
def grab_json_response(self, url, data=None, referer=None):
|
||||
webclient = self.dupe()
|
||||
if data:
|
||||
self.request('POST', url, data, referer=referer)
|
||||
webclient.request('POST', url, data, referer=referer)
|
||||
else:
|
||||
self.request('GET', url, referer=referer)
|
||||
rsp = self.getresponse()
|
||||
webclient.request('GET', url, referer=referer)
|
||||
rsp = webclient.getresponse()
|
||||
if rsp.status == 200:
|
||||
return json.loads(rsp.read())
|
||||
rsp.read()
|
||||
@ -138,8 +139,9 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
form = get_upload_form(filename, data, formname, otherfields)
|
||||
ulheaders = self.stdheaders.copy()
|
||||
ulheaders['Content-Type'] = 'multipart/form-data; boundary=' + BND
|
||||
self.request('POST', url, form, ulheaders)
|
||||
rsp = self.getresponse()
|
||||
webclient = self.dupe()
|
||||
webclient.request('POST', url, form, ulheaders)
|
||||
rsp = webclient.getresponse()
|
||||
# peer updates in progress should already have pointers,
|
||||
# subsequent transactions will cause memory to needlessly double,
|
||||
# but easiest way to keep memory relatively low
|
||||
|
Loading…
x
Reference in New Issue
Block a user