Skip to content

Commit

Permalink
Refactor: Correct polling infrequent usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
pfranck committed Jul 8, 2024
1 parent ba5fd0f commit af2c5c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion polling/infrequent/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class ComposeGreetingInput:

@activity.defn
async def compose_greeting(input: ComposeGreetingInput) -> str:
test_service = TestService()
attempt = activity.info().attempt - 1
test_service = TestService(attempt=attempt)
# If this raises an exception because it's not done yet, the activity will
# continually be scheduled for retry
return await test_service.get_service_result(input)
6 changes: 3 additions & 3 deletions polling/test_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class TestService:
def __init__(self):
self.try_attempts = 0
self.error_attempts = 5
def __init__(self, attempt=0, error_attempts=5):
self.try_attempts = attempt
self.error_attempts = error_attempts

async def get_service_result(self, input):
print(
Expand Down

0 comments on commit af2c5c2

Please sign in to comment.