diff --git a/skynet/frontend/telegram/__init__.py b/skynet/frontend/telegram/__init__.py index 3fcbeb9..33798c5 100644 --- a/skynet/frontend/telegram/__init__.py +++ b/skynet/frontend/telegram/__init__.py @@ -1,5 +1,6 @@ #!/usr/bin/python +from json import JSONDecodeError import random import logging import asyncio @@ -188,25 +189,29 @@ class SkynetTelegramFrontend: tx_hash = None ipfs_hash = None for i in range(60): - submits = await self.hyperion.aget_actions( - account=self.account, - filter='telos.gpu:submit', - sort='desc', - after=request_time - ) - actions = [ - action - for action in submits['actions'] - if action[ - 'act']['data']['request_hash'] == request_hash - ] - if len(actions) > 0: - tx_hash = actions[0]['trx_id'] - data = actions[0]['act']['data'] - ipfs_hash = data['ipfs_hash'] - worker = data['worker'] - logging.info('Found matching submit!') - break + try: + submits = await self.hyperion.aget_actions( + account=self.account, + filter='telos.gpu:submit', + sort='desc', + after=request_time + ) + actions = [ + action + for action in submits['actions'] + if action[ + 'act']['data']['request_hash'] == request_hash + ] + if len(actions) > 0: + tx_hash = actions[0]['trx_id'] + data = actions[0]['act']['data'] + ipfs_hash = data['ipfs_hash'] + worker = data['worker'] + logging.info('Found matching submit!') + break + + except JSONDecodeError: + logging.error(f'network error while getting actions, retry..') await asyncio.sleep(1) diff --git a/skynet/ipfs/pinner.py b/skynet/ipfs/pinner.py index ab443bf..c4aee10 100644 --- a/skynet/ipfs/pinner.py +++ b/skynet/ipfs/pinner.py @@ -88,6 +88,7 @@ class SkynetPinner: resp = await self.ipfs_http.a_pin(cid) if resp.status_code != 200: logging.error(f'error pinning {cid}:\n{resp.text}') + del self._pinned[cid] else: logging.info(f'pinned {cid}')