Run a complete IPython cell asynchronously. Parameters ---------- raw_cell : str The code (including IPython code such as %magic functions) to run. store_history : bool If True, the raw and translated cell will be stored in IPython's his
(
self,
raw_cell: str,
store_history=False,
silent=False,
shell_futures=True,
*,
transformed_cell: Optional[str] = None,
preprocessing_exc_tuple: Optional[Any] = None
)
| 2972 | return _should_be_async(cell) |
| 2973 | |
| 2974 | async def run_cell_async( |
| 2975 | self, |
| 2976 | raw_cell: str, |
| 2977 | store_history=False, |
| 2978 | silent=False, |
| 2979 | shell_futures=True, |
| 2980 | *, |
| 2981 | transformed_cell: Optional[str] = None, |
| 2982 | preprocessing_exc_tuple: Optional[Any] = None |
| 2983 | ) -> ExecutionResult: |
| 2984 | """Run a complete IPython cell asynchronously. |
| 2985 | |
| 2986 | Parameters |
| 2987 | ---------- |
| 2988 | raw_cell : str |
| 2989 | The code (including IPython code such as %magic functions) to run. |
| 2990 | store_history : bool |
| 2991 | If True, the raw and translated cell will be stored in IPython's |
| 2992 | history. For user code calling back into IPython's machinery, this |
| 2993 | should be set to False. |
| 2994 | silent : bool |
| 2995 | If True, avoid side-effects, such as implicit displayhooks and |
| 2996 | and logging. silent=True forces store_history=False. |
| 2997 | shell_futures : bool |
| 2998 | If True, the code will share future statements with the interactive |
| 2999 | shell. It will both be affected by previous __future__ imports, and |
| 3000 | any __future__ imports in the code will affect the shell. If False, |
| 3001 | __future__ imports are not shared in either direction. |
| 3002 | transformed_cell: str |
| 3003 | cell that was passed through transformers |
| 3004 | preprocessing_exc_tuple: |
| 3005 | trace if the transformation failed. |
| 3006 | |
| 3007 | Returns |
| 3008 | ------- |
| 3009 | result : :class:`ExecutionResult` |
| 3010 | |
| 3011 | .. versionadded: 7.0 |
| 3012 | """ |
| 3013 | info = ExecutionInfo( |
| 3014 | raw_cell, store_history, silent, shell_futures) |
| 3015 | result = ExecutionResult(info) |
| 3016 | |
| 3017 | if (not raw_cell) or raw_cell.isspace(): |
| 3018 | self.last_execution_succeeded = True |
| 3019 | self.last_execution_result = result |
| 3020 | return result |
| 3021 | |
| 3022 | if silent: |
| 3023 | store_history = False |
| 3024 | |
| 3025 | if store_history: |
| 3026 | result.execution_count = self.execution_count |
| 3027 | |
| 3028 | def error_before_exec(value): |
| 3029 | if store_history: |
| 3030 | self.execution_count += 1 |
| 3031 | result.error_before_exec = value |