|
1 | 1 | """An in-process qt console app.""" |
| 2 | + |
2 | 3 | import os |
3 | | -import sys |
4 | 4 |
|
5 | 5 | import tornado |
6 | 6 | from IPython.lib import guisupport |
7 | 7 | from qtconsole.inprocess import QtInProcessKernelManager |
8 | 8 | from qtconsole.rich_ipython_widget import RichIPythonWidget |
9 | 9 |
|
| 10 | +assert tornado.version_info >= (6, 1) |
| 11 | + |
10 | 12 |
|
11 | 13 | def print_process_id(): |
12 | 14 | """Print the process id.""" |
13 | 15 | print("Process ID is:", os.getpid()) |
14 | 16 |
|
15 | 17 |
|
16 | | -def init_asyncio_patch(): |
17 | | - """set default asyncio policy to be compatible with tornado |
18 | | - Tornado 6 (at least) is not compatible with the default |
19 | | - asyncio implementation on Windows |
20 | | - Pick the older SelectorEventLoopPolicy on Windows |
21 | | - if the known-incompatible default policy is in use. |
22 | | - do this as early as possible to make it a low priority and overridable |
23 | | - ref: https://github.com/tornadoweb/tornado/issues/2608 |
24 | | - FIXME: if/when tornado supports the defaults in asyncio, |
25 | | - remove and bump tornado requirement for py38 |
26 | | - """ |
27 | | - if ( |
28 | | - sys.platform.startswith("win") |
29 | | - and sys.version_info >= (3, 8) |
30 | | - and tornado.version_info < (6, 1) |
31 | | - ): |
32 | | - import asyncio |
33 | | - |
34 | | - try: |
35 | | - from asyncio import WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicy |
36 | | - except ImportError: |
37 | | - pass |
38 | | - # not affected |
39 | | - else: |
40 | | - if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy: |
41 | | - # WindowsProactorEventLoopPolicy is not compatible with tornado 6 |
42 | | - # fallback to the pre-3.8 default of Selector |
43 | | - asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy()) |
44 | | - |
45 | | - |
46 | 18 | def main(): |
47 | 19 | """The main entry point.""" |
48 | 20 | # Print the ID of the main process |
49 | 21 | print_process_id() |
50 | 22 |
|
51 | | - init_asyncio_patch() |
52 | 23 | app = guisupport.get_app_qt4() |
53 | 24 |
|
54 | 25 | # Create an in-process kernel |
|
0 commit comments