Show More
@@ -695,6 +695,13 b' class InteractiveShell(SingletonConfigurable):' | |||||
695 | self.events.trigger('shell_initialized', self) |
|
695 | self.events.trigger('shell_initialized', self) | |
696 | atexit.register(self.atexit_operations) |
|
696 | atexit.register(self.atexit_operations) | |
697 |
|
697 | |||
|
698 | # The trio runner is used for running Trio in the foreground thread. It | |||
|
699 | # is different from `_trio_runner(async_fn)` in `async_helpers.py` | |||
|
700 | # which calls `trio.run()` for every cell. This runner runs all cells | |||
|
701 | # inside a single Trio event loop. If used, it is set from | |||
|
702 | # `ipykernel.kernelapp`. | |||
|
703 | self.trio_runner = None | |||
|
704 | ||||
698 | def get_ipython(self): |
|
705 | def get_ipython(self): | |
699 | """Return the currently running IPython instance.""" |
|
706 | """Return the currently running IPython instance.""" | |
700 | return self |
|
707 | return self | |
@@ -715,6 +722,9 b' class InteractiveShell(SingletonConfigurable):' | |||||
715 | else: |
|
722 | else: | |
716 | self.autoindent = value |
|
723 | self.autoindent = value | |
717 |
|
724 | |||
|
725 | def set_trio_runner(self, tr): | |||
|
726 | self.trio_runner = tr | |||
|
727 | ||||
718 | #------------------------------------------------------------------------- |
|
728 | #------------------------------------------------------------------------- | |
719 | # init_* methods called by __init__ |
|
729 | # init_* methods called by __init__ | |
720 | #------------------------------------------------------------------------- |
|
730 | #------------------------------------------------------------------------- | |
@@ -2865,7 +2875,9 b' class InteractiveShell(SingletonConfigurable):' | |||||
2865 | # when this is the case, we want to run it using the pseudo_sync_runner |
|
2875 | # when this is the case, we want to run it using the pseudo_sync_runner | |
2866 | # so that code can invoke eventloops (for example via the %run , and |
|
2876 | # so that code can invoke eventloops (for example via the %run , and | |
2867 | # `%paste` magic. |
|
2877 | # `%paste` magic. | |
2868 |
if self. |
|
2878 | if self.trio_runner: | |
|
2879 | runner = self.trio_runner | |||
|
2880 | elif self.should_run_async(raw_cell): | |||
2869 | runner = self.loop_runner |
|
2881 | runner = self.loop_runner | |
2870 | else: |
|
2882 | else: | |
2871 | runner = _pseudo_sync_runner |
|
2883 | runner = _pseudo_sync_runner |
General Comments 0
You need to be logged in to leave comments.
Login now