Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def __init__(self, family=-1, type=-1, proto=-1, fileno=None):
socket_module.socket = BlockedSocket # Blocks: import socket; socket.socket()

shell = TerminalInteractiveShell()
# TerminalInteractiveShell installs a SIGINT handler that calls sys.exit(0)
# instead of raising KeyboardInterrupt when _executing is False (which is
# the case when run_cell is called programmatically). Restore the default
# handler so SIGINT raises KeyboardInterrupt and our except clause catches it.
signal.signal(signal.SIGINT, signal.SIG_DFL)
try:
while True:
try:
Expand Down Expand Up @@ -203,7 +208,7 @@ def stop_shell(self, shell_id):
proc.terminate()
proc.join(timeout=2.0)

def run_cell(self, shell_id, code, timeout=1.0, grace=0.5, traceback_verbosity="Plain"):
def run_cell(self, shell_id, code, timeout=1.0, grace=2.0, traceback_verbosity="Plain"):
"""
Execute `code` on shell `shell_id`.
- timeout: seconds to wait for normal completion
Expand Down Expand Up @@ -427,7 +432,7 @@ def execute_ipython_session(generated_code, session_id, timeout=30, traceback_ve

# Execute code using ShellManager with proper timeout and cancellation
result = shell_manager.run_cell(
session_id, generated_code, timeout=timeout, grace=0.5, traceback_verbosity=traceback_verbosity
session_id, generated_code, timeout=timeout, grace=2.0, traceback_verbosity=traceback_verbosity
)

# Determine if this is effectively a new session
Expand Down
Loading