mirror of https://github.com/skygpu/skynet.git
				
				
				
			Make frontend more resilient and remove from pinned on error to allow retry
							parent
							
								
									44bfc5e9e7
								
							
						
					
					
						commit
						120d97f478
					
				|  | @ -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,25 +189,29 @@ class SkynetTelegramFrontend: | ||||||
|         tx_hash = None |         tx_hash = None | ||||||
|         ipfs_hash = None |         ipfs_hash = None | ||||||
|         for i in range(60): |         for i in range(60): | ||||||
|             submits = await self.hyperion.aget_actions( |             try: | ||||||
|                 account=self.account, |                 submits = await self.hyperion.aget_actions( | ||||||
|                 filter='telos.gpu:submit', |                     account=self.account, | ||||||
|                 sort='desc', |                     filter='telos.gpu:submit', | ||||||
|                 after=request_time |                     sort='desc', | ||||||
|             ) |                     after=request_time | ||||||
|             actions = [ |                 ) | ||||||
|                 action |                 actions = [ | ||||||
|                 for action in submits['actions'] |                     action | ||||||
|                 if action[ |                     for action in submits['actions'] | ||||||
|                     'act']['data']['request_hash'] == request_hash |                     if action[ | ||||||
|             ] |                         'act']['data']['request_hash'] == request_hash | ||||||
|             if len(actions) > 0: |                 ] | ||||||
|                 tx_hash = actions[0]['trx_id'] |                 if len(actions) > 0: | ||||||
|                 data = actions[0]['act']['data'] |                     tx_hash = actions[0]['trx_id'] | ||||||
|                 ipfs_hash = data['ipfs_hash'] |                     data = actions[0]['act']['data'] | ||||||
|                 worker = data['worker'] |                     ipfs_hash = data['ipfs_hash'] | ||||||
|                 logging.info('Found matching submit!') |                     worker = data['worker'] | ||||||
|                 break |                     logging.info('Found matching submit!') | ||||||
|  |                     break | ||||||
|  | 
 | ||||||
|  |             except JSONDecodeError: | ||||||
|  |                 logging.error(f'network error while getting actions, retry..') | ||||||
| 
 | 
 | ||||||
|             await asyncio.sleep(1) |             await asyncio.sleep(1) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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}') | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue