Skip to content

Commit e3ae39c

Browse files
authored
Remove some potential dead-code. (#1273)
1 parent a991039 commit e3ae39c

File tree

4 files changed

+6
-56
lines changed

4 files changed

+6
-56
lines changed

examples/embedding/inprocess_qtconsole.py

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,24 @@
11
"""An in-process qt console app."""
22
import os
3-
import sys
43

54
import tornado
65
from IPython.lib import guisupport
76
from qtconsole.inprocess import QtInProcessKernelManager
87
from qtconsole.rich_ipython_widget import RichIPythonWidget
98

9+
assert tornado.version_info >= (6, 1)
10+
1011

1112
def print_process_id():
1213
"""Print the process id."""
1314
print("Process ID is:", os.getpid())
1415

1516

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-
4617
def main():
4718
"""The main entry point."""
4819
# Print the ID of the main process
4920
print_process_id()
5021

51-
init_asyncio_patch()
5222
app = guisupport.get_app_qt4()
5323

5424
# Create an in-process kernel

ipykernel/kernelapp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def _init_asyncio_patch(self):
657657
where asyncio.ProactorEventLoop supports add_reader and friends.
658658
659659
"""
660-
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
660+
if sys.platform.startswith("win"):
661661
import asyncio
662662

663663
try:

tests/test_eventloop.py

+1-21
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import time
88

99
import pytest
10-
import tornado
1110

1211
from ipykernel.eventloops import (
1312
enable_gui,
@@ -16,7 +15,7 @@
1615
loop_tk,
1716
)
1817

19-
from .utils import execute, flush_channels, start_new_kernel
18+
from .utils import flush_channels, start_new_kernel
2019

2120
KC = KM = None
2221

@@ -61,25 +60,6 @@ def _setup_env():
6160
"""
6261

6362

64-
@pytest.mark.skipif(tornado.version_info < (5,), reason="only relevant on tornado 5")
65-
def test_asyncio_interrupt():
66-
assert KM is not None
67-
assert KC is not None
68-
flush_channels(KC)
69-
msg_id, content = execute("%gui asyncio", KC)
70-
assert content["status"] == "ok", content
71-
72-
flush_channels(KC)
73-
msg_id, content = execute(async_code, KC)
74-
assert content["status"] == "ok", content
75-
76-
KM.interrupt_kernel()
77-
78-
flush_channels(KC)
79-
msg_id, content = execute(async_code, KC)
80-
assert content["status"] == "ok"
81-
82-
8363
windows_skip = pytest.mark.skipif(os.name == "nt", reason="causing failures on windows")
8464

8565

tests/test_kernel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_sys_path_profile_dir():
212212

213213
@flaky(max_runs=3)
214214
@pytest.mark.skipif(
215-
sys.platform == "win32" or (sys.platform == "darwin" and sys.version_info >= (3, 8)),
215+
sys.platform == "win32" or (sys.platform == "darwin"),
216216
reason="subprocess prints fail on Windows and MacOS Python 3.8+",
217217
)
218218
def test_subprocess_print():
@@ -267,7 +267,7 @@ def test_subprocess_noprint():
267267

268268
@flaky(max_runs=3)
269269
@pytest.mark.skipif(
270-
sys.platform == "win32" or (sys.platform == "darwin" and sys.version_info >= (3, 8)),
270+
(sys.platform == "win32") or (sys.platform == "darwin"),
271271
reason="subprocess prints fail on Windows and MacOS Python 3.8+",
272272
)
273273
def test_subprocess_error():

0 commit comments

Comments
 (0)