Skip to content

Commit

Permalink
fix: extra exception printing
Browse files Browse the repository at this point in the history
  • Loading branch information
xadahiya committed Oct 19, 2024
1 parent b661133 commit 1e07590
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions snapshotter/utils/generic_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from typing import Set
from typing import Union
from uuid import uuid4

import grpclib
import httpx
import sha3
Expand Down Expand Up @@ -650,14 +651,15 @@ async def _send_submission_to_collector(self, snapshot_cid, epoch_id, project_id
try:
await self.send_message(msg=msg, **kwargs_simulation)
except Exception as e:
if isinstance(e, grpclib.exceptions.StreamTerminatedError):
pass # fail silently as this is intended for the stream to be closed right after sending the message
if 'StreamTerminatedError' in str(e): # Doing this because we get RetryError here not StreamTerminatedError
pass # fail silently as this is intended for the stream to be closed right after sending the message
else:
self._logger.error(f'Probable exception in _send_submission_to_collector while sending snapshot to local collector {msg}: {e}')
self._logger.error(
f'Probable exception in _send_submission_to_collector while sending snapshot to local collector {msg}: {e}',
)
else:
self._logger.info('In _send_submission_to_collector successfully sent snapshot to local collector {msg}')


@retry(
wait=wait_random_exponential(multiplier=1, max=10),
stop=stop_after_attempt(3),
Expand All @@ -683,7 +685,7 @@ async def send_message(self, msg, simulation=False):
await stream.end()
self._logger.debug(f'gRPC stream ended for snapshot {msg}')
except (ConnectionResetError, grpclib.exceptions.StreamTerminatedError) as e:
pass # fail silently as this is intended for the stream to be closed right after sending the message
pass # fail silently as this is intended for the stream to be closed right after sending the message
except asyncio.CancelledError:
self._logger.info('Task to send snapshot to local collector was asyncio cancelled! {}', msg)
else:
Expand Down

0 comments on commit 1e07590

Please sign in to comment.