@@ -30,7 +30,6 @@ def __init__(self, feed_ids: list[str], endpoint=HERMES_ENDPOINT_HTTPS, ws_endpo
30
30
self .feed_ids = feed_ids
31
31
self .pending_feed_ids = feed_ids
32
32
self .prices_dict : dict [str , PriceFeed ] = {}
33
- self .client = httpx .AsyncClient ()
34
33
self .endpoint = endpoint
35
34
self .ws_endpoint = ws_endpoint
36
35
self .feed_batch_size = feed_batch_size # max number of feed IDs to query at once in https requests
@@ -42,7 +41,8 @@ async def get_price_feed_ids(self) -> list[str]:
42
41
43
42
url = os .path .join (self .endpoint , "api/price_feed_ids" )
44
43
45
- data = (await self .client .get (url )).json ()
44
+ async with httpx .AsyncClient () as client :
45
+ data = (await client .get (url )).json ()
46
46
47
47
return data
48
48
@@ -102,7 +102,8 @@ async def get_pyth_prices_latest(self, feedIds: list[str], version=2) -> list[Pr
102
102
else :
103
103
parse_unsupported_version (version )
104
104
105
- data = (await self .client .get (url , params = params )).json ()
105
+ async with httpx .AsyncClient () as client :
106
+ data = (await client .get (url , params = params )).json ()
106
107
107
108
if version == 1 :
108
109
results = []
@@ -127,7 +128,8 @@ async def get_pyth_price_at_time(self, feed_id: str, timestamp: int, version=2)
127
128
else :
128
129
parse_unsupported_version (version )
129
130
130
- data = (await self .client .get (url , params = params )).json ()
131
+ async with httpx .AsyncClient () as client :
132
+ data = (await client .get (url , params = params )).json ()
131
133
132
134
if version == 1 :
133
135
price_feed = self .extract_price_feed_v1 (data )
0 commit comments