Skip to content
Open
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
7 changes: 6 additions & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import signal
import socket
import typing
import asyncio
import inspect
import weakref
import builtins
Expand All @@ -102,6 +101,8 @@
from types import CodeType
from warnings import deprecated

lazy import asyncio

try:
import _pyrepl.utils
except ModuleNotFoundError:
Expand Down Expand Up @@ -902,6 +903,10 @@ def _hold_exceptions(self, exceptions):
self._chained_exception_index = 0

def _get_asyncio_task(self):
# If asyncio has never been imported there cannot be a running task,
# so skip the import rather than pay for it on every interaction.
if 'asyncio' not in sys.modules:
return None
try:
task = asyncio.current_task()
except RuntimeError:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Speed up :mod:`pdb` startup by only importing :mod:`asyncio` when the program
being debugged has already imported it.
Loading