@@ -385,6 +385,7 @@ def _calculate_backoff(self, attempt: int):
385385 return min (self ._max_backoff , self ._min_backoff * (2 ** (attempt + 1 )))
386386
387387 def _handle_unhealthy_node (self , proto_request , attempt , logger , err ) -> bool :
388+ """Hnadle node switching and backoff for unhealthy node"""
388389 # Check if the request is a transaction receipt or record because they are single node requests
389390 if _is_transaction_receipt_or_record_request (proto_request ):
390391 _delay_for_attempt (
@@ -452,17 +453,7 @@ def _execute(self, client: "Client", timeout: Optional[Union[int, float]] = None
452453 # Create a channel wrapper from the client's channel
453454 channel = node ._get_channel ()
454455
455- logger .trace (
456- "Executing" ,
457- "requestId" ,
458- self ._get_request_id (),
459- "nodeAccountID" ,
460- self .node_account_id ,
461- "attempt" ,
462- attempt + 1 ,
463- "maxAttempts" ,
464- self ._max_attempts ,
465- )
456+ logger .trace ("Executing" , "requestId" , self ._get_request_id (), "nodeAccountID" , self .node_account_id , "attempt" , attempt + 1 , "maxAttempts" , self ._max_attempts ,)
466457
467458 # Get the appropriate gRPC method to call
468459 method = self ._get_method (channel )
@@ -495,17 +486,7 @@ def _execute(self, client: "Client", timeout: Optional[Union[int, float]] = None
495486
496487 # Determine if we should retry based on the response
497488 execution_state = self ._should_retry (response )
498- logger .trace (
499- f"{ self .__class__ .__name__ } status received" ,
500- "nodeAccountID" ,
501- self .node_account_id ,
502- "network" ,
503- client .network .network ,
504- "state" ,
505- execution_state .name ,
506- "txID" ,
507- tx_id ,
508- )
489+ logger .trace (f"{ self .__class__ .__name__ } status received" , "nodeAccountID" , self .node_account_id , "network" , client .network .network , "state" , execution_state .name , "txID" , tx_id ,)
509490
510491 # Handle the execution state
511492 match execution_state :
@@ -537,13 +518,7 @@ def _execute(self, client: "Client", timeout: Optional[Union[int, float]] = None
537518 response , self .node_account_id , proto_request
538519 )
539520
540- logger .error (
541- "Exceeded maximum attempts for request" ,
542- "requestId" ,
543- self ._get_request_id (),
544- "last exception being" ,
545- err_persistant ,
546- )
521+ logger .error ("Exceeded maximum attempts for request" , "requestId" , self ._get_request_id (), "last exception being" , err_persistant ,)
547522 raise MaxAttemptsError (
548523 "Exceeded maximum attempts or request timeout" ,
549524 self .node_account_id ,
@@ -568,17 +543,7 @@ def _delay_for_attempt(request_id: str, backoff: float, attempt: int, logger, er
568543 attempt (int): The current attempt number (0-based)
569544 backoff (float): The current backoff period in seconds
570545 """
571- logger .trace (
572- f"Retrying request attempt" ,
573- "requestId" ,
574- request_id ,
575- "delay" ,
576- backoff ,
577- "attempt" ,
578- attempt ,
579- "error" ,
580- error ,
581- )
546+ logger .trace (f"Retrying request attempt" , "requestId" , request_id , "delay" , backoff , "attempt" , attempt , "error" , error ,)
582547 time .sleep (backoff )
583548
584549
0 commit comments