Debugging our Code
Let’s go ahead and fix the exception in our Activity code by removing the raised exception or commenting it out and re-running our code to register the code change.
In practice, your code will continue retrying until whatever issue the Activity has encountered has resolved itself, whether that is the network coming back online or an internal service starting to respond again.
By leveraging the durability of Temporal and out of the box retry capabilities, you have avoided writing retry and timeout logic yourself and saved your downstream services from being unnecessarily overwhelmed.
from temporalio import activity
@activity.defn
async def withdraw_money(amount: float) -> bool:
# raise Exception('Bank service temporarily unavailable')
print(f"Successfully withdrawn ${amount}")
return True
@activity.defn
async def deposit_money(amount: float) -> bool:
print(f"Successfully deposited ${amount}")
return True