Skip to content

Commit ff9c533

Browse files
author
Roman
committed
checker
1 parent afb5f3d commit ff9c533

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bittensor/core/subtensor_api/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,31 @@ def __repr__(self):
144144
return self.__str__()
145145

146146
def __enter__(self):
147+
if self.is_async:
148+
raise NotImplementedError(
149+
"Async version of SubtensorApi cannot be used with sync context manager."
150+
)
147151
return self
148152

149153
def __exit__(self, exc_type, exc_val, exc_tb):
154+
if self.is_async:
155+
raise NotImplementedError(
156+
"Async version of SubtensorApi cannot be used with sync context manager."
157+
)
150158
self.close()
151159

152160
async def __aenter__(self):
161+
if not self.is_async:
162+
raise NotImplementedError(
163+
"Sync version of SubtensorApi cannot be used with async context manager."
164+
)
153165
return await self._subtensor.__aenter__()
154166

155167
async def __aexit__(self, exc_type, exc_val, exc_tb):
168+
if not self.is_async:
169+
raise NotImplementedError(
170+
"Sync version of SubtensorApi cannot be used with async context manager."
171+
)
156172
await self.substrate.close()
157173

158174
@classmethod

0 commit comments

Comments
 (0)