Skip to content

Commit 11bb2f9

Browse files
authored
chore: Added missing timeout support for some execute() implementations (hiero-ledger#1736)
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent d1c19f7 commit 11bb2f9

15 files changed

Lines changed: 30 additions & 24 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
296296
- Update `.github/scripts/bot-advanced-check.sh` to unassign unqualified users.
297297
- Fixed broken project structure link in `CONTRIBUTING.md` (#1664)
298298
- Refactor spam list update logic and remove unused pull request creation step `.github/scripts/update-spam-list.js` `.github/workflows/cron-update-spam-list.yml`.
299+
- Ensure all Query sub-class `execute()` function to correctly propagate the optional `timeout` parameter.
299300

300301
### Removed
301302

src/hiero_sdk_python/account/account_records_query.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import traceback
6-
from typing import List, Optional
6+
from typing import List, Optional, Union
77

88
from hiero_sdk_python.account.account_id import AccountId
99
from hiero_sdk_python.channels import _Channel
@@ -96,7 +96,7 @@ def _get_method(self, channel: _Channel) -> _Method:
9696
"""
9797
return _Method(transaction_func=None, query_func=channel.crypto.getAccountRecords)
9898

99-
def execute(self, client: Client) -> List[TransactionRecord]:
99+
def execute(self, client: Client, timeout: Optional[Union[int, float]] = None) -> List[TransactionRecord]:
100100
"""
101101
Executes the account records query.
102102
@@ -108,6 +108,7 @@ def execute(self, client: Client) -> List[TransactionRecord]:
108108
109109
Args:
110110
client (Client): The client instance to use for execution
111+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
111112
112113
Returns:
113114
List[TransactionRecord]: The account records from the network
@@ -118,7 +119,7 @@ def execute(self, client: Client) -> List[TransactionRecord]:
118119
ReceiptStatusError: If the query fails with a receipt status error
119120
"""
120121
self._before_execute(client)
121-
response = self._execute(client)
122+
response = self._execute(client, timeout)
122123

123124
records = []
124125
for record in response.cryptoGetAccountRecords.records:

src/hiero_sdk_python/contract/contract_bytecode_query.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import traceback
6-
from typing import Optional
6+
from typing import Optional, Union
77

88
from hiero_sdk_python.channels import _Channel
99
from hiero_sdk_python.client.client import Client
@@ -106,7 +106,7 @@ def _get_method(self, channel: _Channel) -> _Method:
106106
transaction_func=None, query_func=channel.smart_contract.ContractGetBytecode
107107
)
108108

109-
def execute(self, client: Client) -> bytes:
109+
def execute(self, client: Client, timeout: Optional[Union[int, float]] = None) -> bytes:
110110
"""
111111
Executes the contract bytecode query.
112112
@@ -118,6 +118,7 @@ def execute(self, client: Client) -> bytes:
118118
119119
Args:
120120
client (Client): The client instance to use for execution
121+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
121122
122123
Returns:
123124
bytes: The bytecode of the contract from the network
@@ -128,7 +129,7 @@ def execute(self, client: Client) -> bytes:
128129
ReceiptStatusError: If the query fails with a receipt status error
129130
"""
130131
self._before_execute(client)
131-
response = self._execute(client)
132+
response = self._execute(client, timeout)
132133

133134
return response.contractGetBytecodeResponse.bytecode
134135

src/hiero_sdk_python/contract/contract_call_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def execute(self, client: Client, timeout: Optional[Union[int, float]] = None) -
199199
200200
Args:
201201
client (Client): The client instance to use for execution
202-
timeout (Optional[Union[int, float]): The total execution timeout (in seconds) for this execution.
202+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
203203
204204
Returns:
205205
ContractFunctionResult: The result of the contract call

src/hiero_sdk_python/contract/contract_info_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def execute(self, client: Client, timeout: Optional[Union[int, float]] = None) -
110110
111111
Args:
112112
client (Client): The client instance to use for execution
113-
timeout (Optional[Union[int, float]): The total execution timeout (in seconds) for this execution.
113+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
114114
115115
Returns:
116116
ContractInfo: The contract info from the network

src/hiero_sdk_python/file/file_contents_query.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Query to get the contents of a file on the network.
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Union
66

77
from hiero_sdk_python.channels import _Channel
88
from hiero_sdk_python.client.client import Client
@@ -96,7 +96,7 @@ def _get_method(self, channel: _Channel) -> _Method:
9696
"""
9797
return _Method(transaction_func=None, query_func=channel.file.getFileContent)
9898

99-
def execute(self, client: Client) -> str:
99+
def execute(self, client: Client, timeout: Optional[Union[int, float]] = None) -> str:
100100
"""
101101
Executes the file contents query.
102102
@@ -108,6 +108,7 @@ def execute(self, client: Client) -> str:
108108
109109
Args:
110110
client (Client): The client instance to use for execution
111+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
111112
112113
Returns:
113114
str: The contents of the file from the network
@@ -118,7 +119,7 @@ def execute(self, client: Client) -> str:
118119
ReceiptStatusError: If the query fails with a receipt status error
119120
"""
120121
self._before_execute(client)
121-
response = self._execute(client)
122+
response = self._execute(client, timeout)
122123

123124
return response.fileGetContents.fileContents.contents
124125

src/hiero_sdk_python/file/file_info_query.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import traceback
6-
from typing import Optional
6+
from typing import Optional, Union
77

88
from hiero_sdk_python.channels import _Channel
99
from hiero_sdk_python.client.client import Client
@@ -95,7 +95,7 @@ def _get_method(self, channel: _Channel) -> _Method:
9595
"""
9696
return _Method(transaction_func=None, query_func=channel.file.getFileInfo)
9797

98-
def execute(self, client: Client) -> FileInfo:
98+
def execute(self, client: Client, timeout: Optional[Union[int, float]] = None) -> FileInfo:
9999
"""
100100
Executes the file info query.
101101
@@ -107,6 +107,7 @@ def execute(self, client: Client) -> FileInfo:
107107
108108
Args:
109109
client (Client): The client instance to use for execution
110+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
110111
111112
Returns:
112113
FileInfo: The file info from the network
@@ -117,7 +118,7 @@ def execute(self, client: Client) -> FileInfo:
117118
ReceiptStatusError: If the query fails with a receipt status error
118119
"""
119120
self._before_execute(client)
120-
response = self._execute(client)
121+
response = self._execute(client, timeout)
121122

122123
return FileInfo._from_proto(response.fileGetInfo.fileInfo)
123124

src/hiero_sdk_python/query/account_balance_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def execute(self, client: Client, timeout: Optional[Union[int, float]] = None) -
145145
146146
Args:
147147
client (Client): The client instance to use for execution
148-
timeout (Optional[Union[int, float]): The total execution timeout (in seconds) for this execution.
148+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
149149
150150
Returns:
151151
AccountBalance: The account balance from the network

src/hiero_sdk_python/query/account_info_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ def execute(self, client, timeout: Optional[Union[int, float]] = None):
9898
to return an AccountInfo object.
9999
100100
This function delegates the core logic to `_execute()`, and may propagate exceptions raised by it.
101-
timeout (Optional[Union[int, float]): The total execution timeout (in seconds) for this execution.
102101
103102
Args:
104103
client (Client): The client instance to use for execution
104+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
105105
106106
Returns:
107107
AccountInfo: The account info from the network

src/hiero_sdk_python/query/token_info_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def execute(self, client: Client, timeout: Optional[Union[int, float]] = None) -
101101
102102
Args:
103103
client (Client): The client instance to use for execution
104-
timeout (Optional[Union[int, float]): The total execution timeout (in seconds) for this execution.
104+
timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution.
105105
106106
Returns:
107107
TokenInfo: The token info from the network

0 commit comments

Comments
 (0)