Run the given source code in the interpreter. This is essentially the same as calling the builtin "exec" with this interpreter, using the __dict__ of its __main__ module as both globals and locals. There is no return value. If the code raises an unhandled e
(self, code, /)
| 195 | _interpreters.set___main___attrs(self._id, ns, restrict=True) |
| 196 | |
| 197 | def exec(self, code, /): |
| 198 | """Run the given source code in the interpreter. |
| 199 | |
| 200 | This is essentially the same as calling the builtin "exec" |
| 201 | with this interpreter, using the __dict__ of its __main__ |
| 202 | module as both globals and locals. |
| 203 | |
| 204 | There is no return value. |
| 205 | |
| 206 | If the code raises an unhandled exception then an ExecutionFailed |
| 207 | exception is raised, which summarizes the unhandled exception. |
| 208 | The actual exception is discarded because objects cannot be |
| 209 | shared between interpreters. |
| 210 | |
| 211 | This blocks the current Python thread until done. During |
| 212 | that time, the previous interpreter is allowed to run |
| 213 | in other threads. |
| 214 | """ |
| 215 | excinfo = _interpreters.exec(self._id, code, restrict=True) |
| 216 | if excinfo is not None: |
| 217 | raise ExecutionFailed(excinfo) |
| 218 | |
| 219 | def _call(self, callable, args, kwargs): |
| 220 | res, excinfo = _interpreters.call(self._id, callable, args, kwargs, restrict=True) |