MCPcopy Index your code
hub / github.com/ipython/ipython / should_run_async

Method should_run_async

IPython/core/interactiveshell.py:3243–3283  ·  view source on GitHub ↗

Return whether a cell should be run asynchronously via a coroutine runner Parameters ---------- raw_cell : str The code to be executed Returns ------- result: bool Whether the code needs to be run with a coroutine runner or no

(
        self, raw_cell: str, *, transformed_cell=None, preprocessing_exc_tuple=None
    )

Source from the content-addressed store, hash-verified

3241 return result
3242
3243 def should_run_async(
3244 self, raw_cell: str, *, transformed_cell=None, preprocessing_exc_tuple=None
3245 ) -> bool:
3246 """Return whether a cell should be run asynchronously via a coroutine runner
3247
3248 Parameters
3249 ----------
3250 raw_cell : str
3251 The code to be executed
3252
3253 Returns
3254 -------
3255 result: bool
3256 Whether the code needs to be run with a coroutine runner or not
3257 .. versionadded:: 7.0
3258 """
3259 if not self.autoawait:
3260 return False
3261 if preprocessing_exc_tuple is not None:
3262 return False
3263 assert preprocessing_exc_tuple is None
3264 if transformed_cell is None:
3265 warnings.warn(
3266 "`should_run_async` will not call `transform_cell`"
3267 " automatically in the future. Please pass the result to"
3268 " `transformed_cell` argument and any exception that happen"
3269 " during the"
3270 "transform in `preprocessing_exc_tuple` in"
3271 " IPython 7.17 and above.",
3272 DeprecationWarning,
3273 stacklevel=2,
3274 )
3275 try:
3276 cell = self.transform_cell(raw_cell)
3277 except Exception:
3278 # any exception during transform will be raised
3279 # prior to execution
3280 return False
3281 else:
3282 cell = transformed_cell
3283 return _should_be_async(cell)
3284
3285 async def run_cell_async(
3286 self,

Callers 2

_run_cellMethod · 0.95
test_should_run_asyncFunction · 0.80

Calls 3

transform_cellMethod · 0.95
_should_be_asyncFunction · 0.85
warnMethod · 0.80

Tested by 1

test_should_run_asyncFunction · 0.64