Show More
@@ -449,22 +449,28 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
449 | 449 | else: |
|
450 | 450 | default = '' |
|
451 | 451 | |
|
452 | with patch_stdout(raw=True): | |
|
453 | # In order to make sure that asyncio code written in the | |
|
454 | # interactive shell doesn't interfere with the prompt, we run the | |
|
455 | # prompt in a different event loop. | |
|
456 | # If we don't do this, people could spawn coroutine with a | |
|
457 | # while/true inside which will freeze the prompt. | |
|
452 | # In order to make sure that asyncio code written in the | |
|
453 | # interactive shell doesn't interfere with the prompt, we run the | |
|
454 | # prompt in a different event loop. | |
|
455 | # If we don't do this, people could spawn coroutine with a | |
|
456 | # while/true inside which will freeze the prompt. | |
|
458 | 457 | |
|
458 | try: | |
|
459 | 459 | old_loop = asyncio.get_event_loop() |
|
460 | asyncio.set_event_loop(self.pt_loop) | |
|
461 | try: | |
|
460 | except RuntimeError: | |
|
461 | # This happens when the user used `asyncio.run()`. | |
|
462 | old_loop = None | |
|
463 | ||
|
464 | asyncio.set_event_loop(self.pt_loop) | |
|
465 | try: | |
|
466 | with patch_stdout(raw=True): | |
|
462 | 467 | text = self.pt_app.prompt( |
|
463 | 468 | default=default, |
|
464 | 469 | **self._extra_prompt_options()) |
|
465 |
|
|
|
466 |
|
|
|
467 |
|
|
|
470 | finally: | |
|
471 | # Restore the original event loop. | |
|
472 | asyncio.set_event_loop(old_loop) | |
|
473 | ||
|
468 | 474 | return text |
|
469 | 475 | |
|
470 | 476 | def enable_win_unicode_console(self): |
General Comments 0
You need to be logged in to leave comments.
Login now