Skip to content

Commit af2c5c2

Browse files
committed
Refactor: Correct polling infrequent usecase
1 parent ba5fd0f commit af2c5c2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Diff for: polling/infrequent/activities.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class ComposeGreetingInput:
1313

1414
@activity.defn
1515
async def compose_greeting(input: ComposeGreetingInput) -> str:
16-
test_service = TestService()
16+
attempt = activity.info().attempt - 1
17+
test_service = TestService(attempt=attempt)
1718
# If this raises an exception because it's not done yet, the activity will
1819
# continually be scheduled for retry
1920
return await test_service.get_service_result(input)

Diff for: polling/test_service.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class TestService:
2-
def __init__(self):
3-
self.try_attempts = 0
4-
self.error_attempts = 5
2+
def __init__(self, attempt=0, error_attempts=5):
3+
self.try_attempts = attempt
4+
self.error_attempts = error_attempts
55

66
async def get_service_result(self, input):
77
print(

0 commit comments

Comments
 (0)