@@ -54,6 +54,7 @@ def __init__(self, instance_num: int) -> None:
5454 )
5555 self .base_url = f"http://localhost:{ self .port } "
5656 self .auth = self ._get_auth ()
57+ self .req_timeout = 10
5758
5859 def _get_auth (self ) -> rauth .HTTPBasicAuth | None :
5960 """Get Basic Auth credentials if configured."""
@@ -64,7 +65,7 @@ def _get_auth(self) -> rauth.HTTPBasicAuth | None:
6465 def get_pool_metadata (self , * , pool_id : str , pool_meta_hash : str ) -> PoolMetadata :
6566 """Fetch stake pool metadata from SMASH, returning a `PoolMetadata`."""
6667 url = f"{ self .base_url } /api/v1/metadata/{ pool_id } /{ pool_meta_hash } "
67- response = http_client .get_session ().get (url , auth = self .auth )
68+ response = http_client .get_session ().get (url , auth = self .auth , timeout = 10 )
6869 response .raise_for_status ()
6970 data = response .json ()
7071 return PoolMetadata (
@@ -77,23 +78,29 @@ def get_pool_metadata(self, *, pool_id: str, pool_meta_hash: str) -> PoolMetadat
7778 def delist_pool (self , * , pool_id : str ) -> PoolData :
7879 """Delist a stake pool, returning PoolData on success or a RequestException on failure."""
7980 url = f"{ self .base_url } /api/v1/delist"
80- response = http_client .get_session ().patch (url , json = {"poolId" : pool_id }, auth = self .auth )
81+ response = http_client .get_session ().patch (
82+ url , json = {"poolId" : pool_id }, auth = self .auth , timeout = self .req_timeout
83+ )
8184 response .raise_for_status ()
8285 data = response .json ()
8386 return PoolData (pool_id = data ["poolId" ])
8487
8588 def enlist_pool (self , * , pool_id : str ) -> PoolData :
8689 """Enlist a stake pool, returning PoolData on success or a RequestException on failure."""
8790 url = f"{ self .base_url } /api/v1/enlist"
88- response = http_client .get_session ().patch (url , json = {"poolId" : pool_id }, auth = self .auth )
91+ response = http_client .get_session ().patch (
92+ url , json = {"poolId" : pool_id }, auth = self .auth , timeout = self .req_timeout
93+ )
8994 response .raise_for_status ()
9095 data = response .json ()
9196 return PoolData (pool_id = data ["poolId" ])
9297
9398 def reserve_ticker (self , * , ticker_name : str , pool_hash : str ) -> PoolTicker :
9499 """Reserve a ticker for a stake pool."""
95100 url = f"{ self .base_url } /api/v1/tickers/{ ticker_name } "
96- response = http_client .get_session ().post (url , json = {"poolId" : pool_hash }, auth = self .auth )
101+ response = http_client .get_session ().post (
102+ url , json = {"poolId" : pool_hash }, auth = self .auth , timeout = self .req_timeout
103+ )
97104 response .raise_for_status ()
98105 data = response .json ()
99106 return PoolTicker (name = data ["name" ])
@@ -102,7 +109,7 @@ def get_pool_errors(self, *, pool_id: str, from_date: str | None = None) -> list
102109 """Fetch errors for a specific stake pool."""
103110 url = f"{ self .base_url } /api/v1/errors/{ pool_id } "
104111 params = {"fromDate" : from_date } if from_date else None
105- response = http_client .get_session ().get (url , params = params , auth = self .auth )
112+ response = http_client .get_session ().get (url , params = params , auth = self .auth , timeout = 10 )
106113 response .raise_for_status ()
107114 data = response .json ()
108115 pool_errors = [
@@ -121,7 +128,7 @@ def get_pool_errors(self, *, pool_id: str, from_date: str | None = None) -> list
121128 def get_retired_pools (self ) -> list [PoolData ]:
122129 """Fetch list of retired pools."""
123130 url = f"{ self .base_url } /api/v1/retired"
124- response = http_client .get_session ().get (url , auth = self .auth )
131+ response = http_client .get_session ().get (url , auth = self .auth , timeout = self . req_timeout )
125132 response .raise_for_status ()
126133 data = response .json ()
127134 retired_pools = [PoolData (pool_id = ret_pool ["poolId" ]) for ret_pool in data ]
0 commit comments