MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / _send_recursive

Method _send_recursive

scratchattach/cloud/_base.py:338–352  ·  view source on GitHub ↗
(self, data: str, *, current_depth: int = 0, max_depth=0)

Source from the content-addressed store, hash-verified

336 )
337
338 def _send_recursive(self, data: str, *, current_depth: int = 0, max_depth=0):
339 try:
340 self.websocket.send(data)
341 except Exception:
342 if current_depth < max_depth:
343 sleep_duration = self._PACKET_FAILURE_SLEEPDURATIONS[
344 min(current_depth, len(self._PACKET_FAILURE_SLEEPDURATIONS) - 1)
345 ]
346 time.sleep(sleep_duration)
347 self.connect()
348 time.sleep(sleep_duration)
349 self._send_recursive(data, current_depth=current_depth + 1, max_depth=max_depth)
350 else:
351 self.active_connection = False
352 raise exceptions.CloudConnectionError(f"Sending packet failed {max_depth + 1} tries: {data}")
353
354 def _send_packet(self, packet, *, max_retries=2):
355 self._send_recursive(json.dumps(packet) + "\n", max_depth=max_retries)

Callers 2

_send_packetMethod · 0.95
_send_packet_listMethod · 0.95

Calls 3

connectMethod · 0.95
minFunction · 0.85
sendMethod · 0.80

Tested by

no test coverage detected