Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some potential dead-code. #1273

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 2 additions & 32 deletions examples/embedding/inprocess_qtconsole.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,24 @@
"""An in-process qt console app."""
import os
import sys

import tornado
from IPython.lib import guisupport
from qtconsole.inprocess import QtInProcessKernelManager
from qtconsole.rich_ipython_widget import RichIPythonWidget

assert tornado.version_info >= (6, 1)


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


def init_asyncio_patch():
"""set default asyncio policy to be compatible with tornado
Tornado 6 (at least) is not compatible with the default
asyncio implementation on Windows
Pick the older SelectorEventLoopPolicy on Windows
if the known-incompatible default policy is in use.
do this as early as possible to make it a low priority and overridable
ref: https://github.com/tornadoweb/tornado/issues/2608
FIXME: if/when tornado supports the defaults in asyncio,
remove and bump tornado requirement for py38
"""
if (
sys.platform.startswith("win")
and sys.version_info >= (3, 8)
and tornado.version_info < (6, 1)
):
import asyncio

try:
from asyncio import WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicy
except ImportError:
pass
# not affected
else:
if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
# WindowsProactorEventLoopPolicy is not compatible with tornado 6
# fallback to the pre-3.8 default of Selector
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())


def main():
"""The main entry point."""
# Print the ID of the main process
print_process_id()

init_asyncio_patch()
app = guisupport.get_app_qt4()

# Create an in-process kernel
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def _init_asyncio_patch(self):
where asyncio.ProactorEventLoop supports add_reader and friends.

"""
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
if sys.platform.startswith("win"):
import asyncio

try:
Expand Down
22 changes: 1 addition & 21 deletions tests/test_eventloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import time

import pytest
import tornado

from ipykernel.eventloops import (
enable_gui,
Expand All @@ -16,7 +15,7 @@
loop_tk,
)

from .utils import execute, flush_channels, start_new_kernel
from .utils import flush_channels, start_new_kernel

KC = KM = None

Expand Down Expand Up @@ -61,25 +60,6 @@ def _setup_env():
"""


@pytest.mark.skipif(tornado.version_info < (5,), reason="only relevant on tornado 5")
def test_asyncio_interrupt():
assert KM is not None
assert KC is not None
flush_channels(KC)
msg_id, content = execute("%gui asyncio", KC)
assert content["status"] == "ok", content

flush_channels(KC)
msg_id, content = execute(async_code, KC)
assert content["status"] == "ok", content

KM.interrupt_kernel()

flush_channels(KC)
msg_id, content = execute(async_code, KC)
assert content["status"] == "ok"


windows_skip = pytest.mark.skipif(os.name == "nt", reason="causing failures on windows")


Expand Down
4 changes: 2 additions & 2 deletions tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test_sys_path_profile_dir():

@flaky(max_runs=3)
@pytest.mark.skipif(
sys.platform == "win32" or (sys.platform == "darwin" and sys.version_info >= (3, 8)),
sys.platform == "win32" or (sys.platform == "darwin"),
reason="subprocess prints fail on Windows and MacOS Python 3.8+",
)
def test_subprocess_print():
Expand Down Expand Up @@ -267,7 +267,7 @@ def test_subprocess_noprint():

@flaky(max_runs=3)
@pytest.mark.skipif(
sys.platform == "win32" or (sys.platform == "darwin" and sys.version_info >= (3, 8)),
(sys.platform == "win32") or (sys.platform == "darwin"),
reason="subprocess prints fail on Windows and MacOS Python 3.8+",
)
def test_subprocess_error():
Expand Down
Loading