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

Do not import debugger/debugpy unless needed #1223

Merged
Merged
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
13 changes: 9 additions & 4 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from .comm.comm import BaseComm
from .comm.manager import CommManager
from .compiler import XCachingCompiler
from .debugger import Debugger, _is_debugpy_available
from .eventloops import _use_appnope
from .iostream import OutStream
from .kernelbase import Kernel as KernelBase
Expand Down Expand Up @@ -75,9 +74,7 @@ class IPythonKernel(KernelBase):
help="Set this flag to False to deactivate the use of experimental IPython completion APIs.",
).tag(config=True)

debugpy_socket = (
Instance(zmq.asyncio.Socket, allow_none=True) if _is_debugpy_available else None
)
debugpy_socket = Instance(zmq.asyncio.Socket, allow_none=True)

user_module = Any()

Expand Down Expand Up @@ -107,6 +104,8 @@ def __init__(self, **kwargs):

self.executing_blocking_code_in_main_shell = False

from .debugger import Debugger, _is_debugpy_available

# Initialize the Debugger
if _is_debugpy_available:
self.debugger = Debugger(
Expand Down Expand Up @@ -214,13 +213,17 @@ async def process_debugpy(self):
tg.cancel_scope.cancel()

async def receive_debugpy_messages(self):
from .debugger import _is_debugpy_available

if not _is_debugpy_available:
return

while True:
await self.receive_debugpy_message()

async def receive_debugpy_message(self, msg=None):
from .debugger import _is_debugpy_available

if not _is_debugpy_available:
return

Expand Down Expand Up @@ -506,6 +509,8 @@ def do_complete(self, code, cursor_pos):

async def do_debug_request(self, msg):
"""Handle a debug request."""
from .debugger import _is_debugpy_available

if _is_debugpy_available:
return await self.debugger.process_request(msg)
return None
Expand Down
Loading