Skip to content

Commit

Permalink
git subrepo clone --branch=separate_cmd_input --force https://github.…
Browse files Browse the repository at this point in the history
…com/impact27/spyder-kernels.git external-deps/spyder-kernels

subrepo:
  subdir:   "external-deps/spyder-kernels"
  merged:   "b53033380"
upstream:
  origin:   "https://github.com/impact27/spyder-kernels.git"
  branch:   "separate_cmd_input"
  commit:   "b53033380"
git-subrepo:
  version:  "0.4.1"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "a04d8c2"
  • Loading branch information
Quentin Peter committed Jul 18, 2020
1 parent 91d7192 commit d11c97f
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 110 deletions.
6 changes: 3 additions & 3 deletions external-deps/spyder-kernels/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
;
[subrepo]
remote = https://github.com/spyder-ide/spyder-kernels.git
branch = 1.x
commit = 1a9d44950edb462188f52cec51c975b80f5f0f6f
parent = adbc02315db0e49bbaa2cd6dae94526264398fc1
branch = separate_cmd_input
commit = b530333803ff9d40a79fdee6632eddf17ec6cd08
parent = 91d71922db18d2f52357009661f8bb522f355435
method = merge
cmdver = 0.4.1
18 changes: 18 additions & 0 deletions external-deps/spyder-kernels/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# History of changes

## Version 1.9.2 (2020-07-10)

### Pull Requests Merged

* [PR 234](https://github.com/spyder-ide/spyder-kernels/pull/234) - PR: Fix a problem caused by ipykernel 5.3.1, by [@ccordoba12](https://github.com/ccordoba12)
* [PR 231](https://github.com/spyder-ide/spyder-kernels/pull/231) - PR: Send comm config on every message, by [@impact27](https://github.com/impact27)
* [PR 230](https://github.com/spyder-ide/spyder-kernels/pull/230) - PR: Send comm config before any wait just to be sure, by [@impact27](https://github.com/impact27)
* [PR 229](https://github.com/spyder-ide/spyder-kernels/pull/229) - PR: Add warning on console if file is not saved, by [@impact27](https://github.com/impact27)
* [PR 228](https://github.com/spyder-ide/spyder-kernels/pull/228) - PR: Fix post_mortem interaction, by [@dalthviz](https://github.com/dalthviz)
* [PR 227](https://github.com/spyder-ide/spyder-kernels/pull/227) - PR: Create a constant for numeric Numpy types, by [@dalthviz](https://github.com/dalthviz)
* [PR 226](https://github.com/spyder-ide/spyder-kernels/pull/226) - PR: Backport PR 225, by [@ccordoba12](https://github.com/ccordoba12)
* [PR 222](https://github.com/spyder-ide/spyder-kernels/pull/222) - PR: Remove the current working directory from sys.path for Python 3.7+, by [@ccordoba12](https://github.com/ccordoba12)
* [PR 220](https://github.com/spyder-ide/spyder-kernels/pull/220) - PR: Make multithreading patch work for all OSes in Python 3, by [@steff456](https://github.com/steff456) ([12465](https://github.com/spyder-ide/spyder/issues/12465))

In this release 9 pull requests were closed.

----

## Version 1.9.1 (2020-05-06)

### Issues Closed
Expand Down
6 changes: 4 additions & 2 deletions external-deps/spyder-kernels/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ To release a new version of spyder-kernels on PyPI:

* Close the respective milestone on Zenhub

* git checkout master
* git checkout 1.x

* git fetch upstream && get merge upstream/master
* git fetch upstream && get merge upstream/1.x

* git clean -xfdi

Expand All @@ -20,6 +20,8 @@ To release a new version of spyder-kernels on PyPI:

* python setup.py bdist_wheel

* twine check dist/*

* twine upload dist/*

* git tag -a vX.X.X -m 'Release X.X.X'
Expand Down
35 changes: 22 additions & 13 deletions external-deps/spyder-kernels/spyder_kernels/comms/frontendcomm.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,35 @@ def remote_call(self, comm_id=None, blocking=False, callback=None,
callback=callback,
timeout=timeout)

# --- Private --------
def _wait_reply(self, call_id, call_name, timeout, retry=True):
"""Wait until the frontend replies to a request."""
if call_id in self._reply_inbox:
return
def wait_until(self, condition, timeout=None):
"""Wait until condition is met. Returns False if timeout."""
if condition():
return True
t_start = time.time()
while call_id not in self._reply_inbox:
if time.time() > t_start + timeout:
if retry:
self._wait_reply(call_id, call_name, timeout, False)
return
raise TimeoutError(
"Timeout while waiting for '{}' reply.".format(
call_name))
while not condition():
if timeout is not None and time.time() > t_start + timeout:
return False
if threading.current_thread() is self.comm_socket_thread:
# Wait for a reply on the comm channel.
self.poll_one()
else:
# Wait 10ms for a reply
time.sleep(0.01)
return True

# --- Private --------
def _wait_reply(self, call_id, call_name, timeout, retry=True):
"""Wait until the frontend replies to a request."""
def reply_recieved():
"""The reply is there!"""
return call_id in self._reply_inbox
if not self.wait_until(reply_recieved):
if retry:
self._wait_reply(call_id, call_name, timeout, False)
return
raise TimeoutError(
"Timeout while waiting for '{}' reply.".format(
call_name))

def _comm_open(self, comm, msg):
"""
Expand Down
83 changes: 61 additions & 22 deletions external-deps/spyder-kernels/spyder_kernels/console/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
# Standard library imports
import os
import sys
import threading

# Third-party imports
from ipykernel.ipkernel import IPythonKernel
from ipython_genutils.py3compat import PY3, input

# Local imports
from spyder_kernels.comms.frontendcomm import FrontendComm
Expand Down Expand Up @@ -58,9 +60,10 @@ def __init__(self, *args, **kwargs):
'set_namespace_view_settings': self.set_namespace_view_settings,
'get_var_properties': self.get_var_properties,
'set_sympy_forecolor': self.set_sympy_forecolor,
'set_pdb_echo_code': self.set_pdb_echo_code,
'update_syspath': self.update_syspath,
'is_special_kernel_valid': self.is_special_kernel_valid
'is_special_kernel_valid': self.is_special_kernel_valid,
'pdb_input_reply': self.pdb_input_reply,
'_interrupt_eventloop': self._interrupt_eventloop,
}
for call_id in handlers:
self.frontend_comm.register_call_handler(
Expand All @@ -70,13 +73,14 @@ def __init__(self, *args, **kwargs):

self._pdb_obj = None
self._pdb_step = None
self._pdb_print_code = True
self._do_publish_pdb_state = True
self._mpl_backend_error = None
self._running_namespace = None
self._pdb_input_line = None

# -- Public API -----------------------------------------------------------
def frontend_call(self, blocking=False, broadcast=True, timeout=None):
def frontend_call(self, blocking=False, broadcast=True,
timeout=None, callback=None):
"""Call the frontend."""
# If not broadcast, send only to the calling comm
if broadcast:
Expand All @@ -87,6 +91,7 @@ def frontend_call(self, blocking=False, broadcast=True, timeout=None):
return self.frontend_comm.remote_call(
blocking=blocking,
comm_id=comm_id,
callback=callback,
timeout=timeout)

# --- For the Variable Explorer
Expand Down Expand Up @@ -254,31 +259,13 @@ def publish_pdb_state(self):
self.frontend_call(blocking=False).pdb_state(state)
self._do_publish_pdb_state = True

def pdb_continue(self):
"""
Tell the console to run 'continue' after entering a
Pdb session to get to the first breakpoint.
Fixes issue 2034
"""
if self._pdb_obj:
self.frontend_call(blocking=False).pdb_continue()

def set_spyder_breakpoints(self, breakpoints):
"""
Handle a message from the frontend
"""
if self._pdb_obj:
self._pdb_obj.set_spyder_breakpoints(breakpoints)

def set_pdb_echo_code(self, state):
"""Set if pdb should echo the code.
This might change for each pdb statment and is therefore not included
in pdb settings.
"""
self._pdb_print_code = state

def set_pdb_ignore_lib(self, state):
"""
Change the "Ignore libraries while stepping" debugger setting.
Expand Down Expand Up @@ -632,3 +619,55 @@ def _load_wurlitzer(self):
get_ipython().run_line_magic('reload_ext', 'wurlitzer')
except Exception:
pass

def cmd_input(self, prompt=''):
"""
Special input function for commands.
Runs the eventloop while debugging.
"""
# Only works if the comm is open and this is a pdb prompt.
if not self.frontend_comm.is_open() or not self._pdb_frame:
return input(prompt)

# Flush output before making the request.
sys.stderr.flush()
sys.stdout.flush()

# Send the input request.
self._pdb_input_line = None
self.frontend_call().pdb_input(prompt)

# Allow GUI event loop to update
if PY3:
is_main_thread = (
threading.current_thread() is threading.main_thread())
else:
is_main_thread = isinstance(
threading.current_thread(), threading._MainThread)

if is_main_thread and self.eventloop:
while self._pdb_input_line is None:
self.eventloop(self)
else:
self.frontend_comm.wait_until(
lambda: self._pdb_input_line is not None)
return self._pdb_input_line

def pdb_input_reply(self, line, echo_stack_entry=True):
"""Get a pdb command from the frontend."""
if self._pdb_obj:
self._pdb_obj._disable_next_stack_entry = not echo_stack_entry
self._pdb_input_line = line
if self.eventloop:
# Interrupting the eventloop is only implemented when a message is
# recieved on the shell channel, but this message is queued and
# won't be processed because an `execute` message is being
# processed. Therefore we process the message here (comm channel)
# and request a dummy message to be sent on the shell channel to
# stop the eventloop. This will call back `_interrupt_eventloop`.
self.frontend_call().request_interrupt_eventloop()

def _interrupt_eventloop(self):
"""Interrupts the eventloop."""
# Recieveing the request is enough to stop the eventloop.
pass
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ def test_do_complete(kernel):
pdb_obj.curframe = inspect.currentframe()
pdb_obj.completenames = lambda *ignore: ['baba']
kernel._pdb_obj = pdb_obj
match = kernel.do_complete('ba', 2)
match = kernel.do_complete('!ba', 2)
assert 'baba' in match['matches']


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import time
import warnings
import logging
import cmd

from IPython.core.getipython import get_ipython

Expand Down Expand Up @@ -311,7 +312,15 @@ def _patched_preparation_data(name):
# =============================================================================
# Pdb adjustments
# =============================================================================
def cmd_input(prompt=''):
return get_ipython().kernel.cmd_input(prompt)


pdb.Pdb = SpyderPdb
if PY2:
cmd.raw_input = cmd_input
else:
cmd.input = cmd_input


# =============================================================================
Expand Down

0 comments on commit d11c97f

Please sign in to comment.