Show More
@@ -81,7 +81,15 b' def safe_watcher():' | |||||
81 | yield |
|
81 | yield | |
82 | return |
|
82 | return | |
83 |
|
83 | |||
84 | loop = policy.get_event_loop() |
|
84 | try: | |
|
85 | loop = policy.get_event_loop() | |||
|
86 | if loop.is_closed(): | |||
|
87 | raise RuntimeError("open a new one") | |||
|
88 | except RuntimeError: | |||
|
89 | # closed loop, make a new one | |||
|
90 | loop = policy.new_event_loop() | |||
|
91 | policy.set_event_loop(loop) | |||
|
92 | ||||
85 | try: |
|
93 | try: | |
86 | watcher = asyncio.SafeChildWatcher() |
|
94 | watcher = asyncio.SafeChildWatcher() | |
87 | watcher.attach_loop(loop) |
|
95 | watcher.attach_loop(loop) | |
@@ -236,9 +244,19 b' class ScriptMagics(Magics):' | |||||
236 | await asyncio.wait([stdout_task, stderr_task]) |
|
244 | await asyncio.wait([stdout_task, stderr_task]) | |
237 | await process.wait() |
|
245 | await process.wait() | |
238 |
|
246 | |||
239 | if sys.platform.startswith("win"): |
|
247 | policy = asyncio.get_event_loop_policy() | |
240 | asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy()) |
|
248 | if sys.platform.startswith("win") and not isinstance( | |
241 | loop = asyncio.get_event_loop_policy().get_event_loop() |
|
249 | policy, asyncio.WindowsProactorEventLoopPolicy | |
|
250 | ): | |||
|
251 | # _do not_ overwrite the current policy | |||
|
252 | policy = asyncio.WindowsProactorEventLoopPolicy() | |||
|
253 | ||||
|
254 | try: | |||
|
255 | loop = policy.get_event_loop() | |||
|
256 | except RuntimeError: | |||
|
257 | # closed loop, make a new one | |||
|
258 | loop = policy.new_event_loop() | |||
|
259 | policy.set_event_loop(loop) | |||
242 | argv = arg_split(line, posix=not sys.platform.startswith("win")) |
|
260 | argv = arg_split(line, posix=not sys.platform.startswith("win")) | |
243 | args, cmd = self.shebang.parser.parse_known_args(argv) |
|
261 | args, cmd = self.shebang.parser.parse_known_args(argv) | |
244 | try: |
|
262 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now