Make frontend more resilient and remove from pinned on error to allow retry

add-txt2txt-models
Guillermo Rodriguez 2023-06-10 09:38:24 -03:00
parent 44bfc5e9e7
commit 120d97f478
No known key found for this signature in database
GPG Key ID: EC3AB66D5D83B392
2 changed files with 25 additions and 19 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
from json import JSONDecodeError
import random import random
import logging import logging
import asyncio import asyncio
@ -188,6 +189,7 @@ class SkynetTelegramFrontend:
tx_hash = None tx_hash = None
ipfs_hash = None ipfs_hash = None
for i in range(60): for i in range(60):
try:
submits = await self.hyperion.aget_actions( submits = await self.hyperion.aget_actions(
account=self.account, account=self.account,
filter='telos.gpu:submit', filter='telos.gpu:submit',
@ -208,6 +210,9 @@ class SkynetTelegramFrontend:
logging.info('Found matching submit!') logging.info('Found matching submit!')
break break
except JSONDecodeError:
logging.error(f'network error while getting actions, retry..')
await asyncio.sleep(1) await asyncio.sleep(1)
if not ipfs_hash: if not ipfs_hash:

View File

@ -88,6 +88,7 @@ class SkynetPinner:
resp = await self.ipfs_http.a_pin(cid) resp = await self.ipfs_http.a_pin(cid)
if resp.status_code != 200: if resp.status_code != 200:
logging.error(f'error pinning {cid}:\n{resp.text}') logging.error(f'error pinning {cid}:\n{resp.text}')
del self._pinned[cid]
else: else:
logging.info(f'pinned {cid}') logging.info(f'pinned {cid}')