Skip to content

Commit 411fb10

Browse files
(fix) Introduce timeoutheight_sync_interval parameter for client
1 parent cd67089 commit 411fb10

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pyinjective/async_client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def __init__(
9999
network: Network,
100100
insecure: Optional[bool] = None,
101101
credentials=None,
102+
timeoutheight_sync_interval: Optional[int] = DEFAULT_TIMEOUTHEIGHT_SYNC_INTERVAL,
102103
):
103104
# the `insecure` parameter is ignored and will be deprecated soon. The value is taken directly from `network`
104105
if insecure is not None:
@@ -154,6 +155,7 @@ def __init__(
154155
self.chain_stream_stub = stream_rpc_grpc.StreamStub(channel=self.chain_stream_channel)
155156

156157
self._timeout_height_sync_task = None
158+
self._timeoutheight_sync_interval = timeoutheight_sync_interval
157159
self._initialize_timeout_height_sync_task()
158160

159161
self._tokens_and_markets_initialization_lock = asyncio.Lock()
@@ -3450,13 +3452,14 @@ async def _tokens_from_official_lists(
34503452
return tokens_by_symbol, tokens_by_denom
34513453

34523454
def _initialize_timeout_height_sync_task(self):
3453-
self._cancel_timeout_height_sync_task()
3454-
self._timeout_height_sync_task = asyncio.get_event_loop().create_task(self._timeout_height_sync_process())
3455+
if self._timeoutheight_sync_interval is not None:
3456+
self._cancel_timeout_height_sync_task()
3457+
self._timeout_height_sync_task = asyncio.get_event_loop().create_task(self._timeout_height_sync_process())
34553458

34563459
async def _timeout_height_sync_process(self):
34573460
while True:
34583461
await self.sync_timeout_height()
3459-
await asyncio.sleep(DEFAULT_TIMEOUTHEIGHT_SYNC_INTERVAL)
3462+
await asyncio.sleep(self._timeoutheight_sync_interval)
34603463

34613464
def _cancel_timeout_height_sync_task(self):
34623465
if self._timeout_height_sync_task is not None:

0 commit comments

Comments
 (0)