File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
bittensor/core/subtensor_api Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -144,15 +144,31 @@ def __repr__(self):
144
144
return self .__str__ ()
145
145
146
146
def __enter__ (self ):
147
+ if self .is_async :
148
+ raise NotImplementedError (
149
+ "Async version of SubtensorApi cannot be used with sync context manager."
150
+ )
147
151
return self
148
152
149
153
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
+ )
150
158
self .close ()
151
159
152
160
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
+ )
153
165
return await self ._subtensor .__aenter__ ()
154
166
155
167
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
+ )
156
172
await self .substrate .close ()
157
173
158
174
@classmethod
You can’t perform that action at this time.
0 commit comments