Skip to content

Commit 5715173

Browse files
committed
chore: address some review sugesstions
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent b1679bc commit 5715173

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/hiero_sdk_python/query/topic_message_query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SubscriptionState:
2929
attempt: int = 0
3030
count: int = 0
3131
last_message: mirror_proto.ConsensusTopicResponse | None = None
32-
pending_messages: dict[str, list[mirror_proto.ConsensusTopicResponse]] = field(default_factory=dict)
32+
pending_messages: dict[TransactionId, list[mirror_proto.ConsensusTopicResponse]] = field(default_factory=dict)
3333

3434

3535
class TopicMessageQuery:
@@ -82,8 +82,8 @@ def set_completion_handler(self, handler: Callable[[], None]) -> TopicMessageQue
8282
self._completion_handler = handler
8383
return self
8484

85-
def set_error_handler(self, handler: Callable[[], None]) -> TopicMessageQuery:
86-
"""Sets a completion handler that is called when the subscription completes."""
85+
def set_error_handler(self, handler: Callable[[Exception], None]) -> TopicMessageQuery:
86+
"""Sets an error handler that is called when the subscription causes an error."""
8787
self._error_handler = handler
8888
return self
8989

@@ -217,6 +217,7 @@ def subscribe(
217217

218218
def run_stream():
219219
while state.attempt < self._max_attempts and not subscription_handle.is_cancelled():
220+
state.attempt += 1
220221
request = self._build_query_request(state)
221222

222223
try:
@@ -247,7 +248,6 @@ def run_stream():
247248
delay = min(0.5 * (2 ** (state.attempt)), self._max_backoff)
248249
logger.warning(f"Error subscribing to topic attempt {state.attempt}. Retrying in {int(delay)}s...")
249250

250-
state.attempt += 1
251251
time.sleep(delay)
252252

253253
thread = threading.Thread(target=run_stream, daemon=True)

0 commit comments

Comments
 (0)