Skip to content

Commit 3bc1c9b

Browse files
committed
Await jasyncio.sleep for charmuhb tries
1 parent 1bf4967 commit 3bc1c9b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

juju/charmhub.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ async def _charmhub_url(self):
1414
model_conf = await self.model.get_config()
1515
return model_conf['charmhub-url']
1616

17-
def request_charmhub_with_retry(self, url, retries):
17+
async def request_charmhub_with_retry(self, url, retries):
1818
for attempt in range(retries):
1919
_response = requests.get(url)
2020
if _response.status_code == 200:
2121
return _response
22-
jasyncio.sleep(5)
22+
await jasyncio.sleep(5)
2323
raise JujuError("Got {} from {}".format(_response.status_code, url))
2424

2525
async def get_charm_id(self, charm_name):
2626
conn, headers, path_prefix = self.model.connection().https_connection()
2727

2828
charmhub_url = await self._charmhub_url()
2929
url = "{}/v2/charms/info/{}".format(charmhub_url.value, charm_name)
30-
_response = self.request_charmhub_with_retry(url, 5)
30+
_response = await self.request_charmhub_with_retry(url, 5)
3131
response = json.loads(_response.text)
3232
return response['id'], response['name']
3333

@@ -36,7 +36,7 @@ async def is_subordinate(self, charm_name):
3636

3737
charmhub_url = await self._charmhub_url()
3838
url = "{}/v2/charms/info/{}?fields=default-release.revision.subordinate".format(charmhub_url.value, charm_name)
39-
_response = self.request_charmhub_with_retry(url, 5)
39+
_response = await self.request_charmhub_with_retry(url, 5)
4040
response = json.loads(_response.text)
4141
return 'subordinate' in response['default-release']['revision']
4242

@@ -48,7 +48,7 @@ async def list_resources(self, charm_name):
4848

4949
charmhub_url = await self._charmhub_url()
5050
url = "{}/v2/charms/info/{}?fields=default-release.resources".format(charmhub_url.value, charm_name)
51-
_response = self.request_charmhub_with_retry(url, 5)
51+
_response = await self.request_charmhub_with_retry(url, 5)
5252
response = json.loads(_response.text)
5353
return response['default-release']['resources']
5454

0 commit comments

Comments
 (0)