| 216 | |
| 217 | |
| 218 | class _EvalAwaitInNewEventLoop(threading.Thread): |
| 219 | def __init__(self, compiled, updated_globals, updated_locals): |
| 220 | threading.Thread.__init__(self) |
| 221 | self.daemon = True |
| 222 | self._compiled = compiled |
| 223 | self._updated_globals = updated_globals |
| 224 | self._updated_locals = updated_locals |
| 225 | |
| 226 | # Output |
| 227 | self.evaluated_value = None |
| 228 | self.exc = None |
| 229 | |
| 230 | async def _async_func(self): |
| 231 | return await eval(self._compiled, self._updated_locals, self._updated_globals) |
| 232 | |
| 233 | def run(self): |
| 234 | try: |
| 235 | import asyncio |
| 236 | |
| 237 | loop = asyncio.new_event_loop() |
| 238 | asyncio.set_event_loop(loop) |
| 239 | self.evaluated_value = asyncio.run(self._async_func()) |
| 240 | except: |
| 241 | self.exc = sys.exc_info() |
| 242 | |
| 243 | |
| 244 | class InteractiveInterpreter: |