Skip to content

Commit

Permalink
Merge branch 'hotfix/1.0.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
agates committed Sep 20, 2021
2 parents 0827bce + 4a405fd commit 93feabb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "podping-hivewriter"
version = "1.0.0"
version = "1.0.1"
license = "MIT"
authors = ["Alecks Gates <[email protected]>", "Brian of London <[email protected]>"]
maintainers = ["Alecks Gates <[email protected]>", "Brian of London <[email protected]>"]
Expand Down
51 changes: 26 additions & 25 deletions src/podping_hivewriter/podping_hivewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,36 +394,37 @@ async def send_notification_iris(self, iris: Set[str], reason="feed_update") ->

return tx_id

async def failure_retry(
self, iri_set: Set[str], failure_count=0
) -> Tuple[str, int]:
async def failure_retry(self, iri_set: Set[str]) -> Tuple[str, int]:
await self.wait_startup()
if failure_count > 0:
logging.warning(f"Waiting {HIVE_HALT_TIMES[failure_count]}s before retry")
await asyncio.sleep(HIVE_HALT_TIMES[failure_count])
logging.info(
f"FAILURE COUNT: {failure_count} - RETRYING {len(iri_set)} IRIs"
)
else:
logging.info(f"Received {len(iri_set)} IRIs")
failure_count = 0

try:
trx_id = await self.send_notification_iris(iris=iri_set)
while True:
if failure_count > 0:
logging.warning(
f"Waiting {HIVE_HALT_TIMES[failure_count]}s before retry"
)
await asyncio.sleep(HIVE_HALT_TIMES[failure_count])
logging.info(
f"----> FAILURE CLEARED after {failure_count} retries <-----"
f"FAILURE COUNT: {failure_count} - RETRYING {len(iri_set)} IRIs"
)
return trx_id, failure_count
except Exception:
logging.warning(f"Failed to send {len(iri_set)} IRIs")
if logging.DEBUG >= logging.root.level:
for iri in iri_set:
logging.debug(iri)
await self.hive_wrapper.rotate_nodes()

# Since this is endless recursion, this could theoretically fail with
# enough retries ... (python doesn't optimize tail recursion)
return await self.failure_retry(iri_set, failure_count + 1)
else:
logging.info(f"Received {len(iri_set)} IRIs")

try:
trx_id = await self.send_notification_iris(iris=iri_set)
if failure_count > 0:
logging.info(
f"----> FAILURE CLEARED after {failure_count} retries <-----"
)
return trx_id, failure_count
except Exception:
logging.warning(f"Failed to send {len(iri_set)} IRIs")
if logging.DEBUG >= logging.root.level:
for iri in iri_set:
logging.debug(iri)
await self.hive_wrapper.rotate_nodes()

failure_count += 1


def get_allowed_accounts(
Expand Down

0 comments on commit 93feabb

Please sign in to comment.