Skip to content

Commit

Permalink
require Python 3.5
Browse files Browse the repository at this point in the history
3.4 doesn't have isawaitable

remove unsupported combinations from test matrix
  • Loading branch information
minrk authored and kevin-bates committed Sep 27, 2019
1 parent a0c96cf commit 56dadf5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 35 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ matrix:
dist: xenial # required for Python >= 3.7 (travis-ci/travis-ci#9069)
- python: 3.6
env: GROUP=docs
- python: 3.6
env:
- GROUP=python
- EXTRA_PIP="tornado<5"

after_success:
- codecov
5 changes: 0 additions & 5 deletions jupyter_server/files/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
import mimetypes
import json
from base64 import decodebytes

from base64 import decodebytes

from tornado import gen, web

from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.utils import maybe_future



class FilesHandler(JupyterHandler):
"""serve files via ContentsManager
Expand Down
4 changes: 0 additions & 4 deletions jupyter_server/services/kernels/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ def post(self, kernel_id, action):
self.log.error("Exception restarting kernel", exc_info=True)
self.set_status(500)
else:
<<<<<<< HEAD
model = yield gen.maybe_future(km.kernel_model(kernel_id))
=======
model = yield maybe_future(km.kernel_model(kernel_id))
>>>>>>> use our own maybe_future
self.write(json.dumps(model, default=date_default))
self.finish()

Expand Down
26 changes: 13 additions & 13 deletions jupyter_server/services/sessions/sessionmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ class SessionManager(LoggingConfigurable):

kernel_manager = Instance('jupyter_server.services.kernels.kernelmanager.MappingKernelManager')
contents_manager = Instance('jupyter_server.services.contents.manager.ContentsManager')

# Session database initialized below
_cursor = None
_connection = None
_columns = {'session_id', 'path', 'name', 'type', 'kernel_id'}

@property
def cursor(self):
"""Start a cursor and create a database called 'session'"""
if self._cursor is None:
self._cursor = self.connection.cursor()
self._cursor.execute("""CREATE TABLE session
self._cursor.execute("""CREATE TABLE session
(session_id, path, name, type, kernel_id)""")
return self._cursor

Expand All @@ -46,7 +46,7 @@ def connection(self):
self._connection = sqlite3.connect(':memory:')
self._connection.row_factory = sqlite3.Row
return self._connection

def close(self):
"""Close the sqlite connection"""
if self._cursor is not None:
Expand Down Expand Up @@ -106,11 +106,11 @@ def start_kernel_for_session(self, session_id, path, name, type, kernel_name):
@gen.coroutine
def save_session(self, session_id, path=None, name=None, type=None, kernel_id=None):
"""Saves the items for the session with the given session_id
Given a session_id (and any other of the arguments), this method
creates a row in the sqlite session database that holds the information
for a session.
Parameters
----------
session_id : str
Expand All @@ -123,7 +123,7 @@ def save_session(self, session_id, path=None, name=None, type=None, kernel_id=No
the type of the session
kernel_id : str
a uuid for the kernel associated with this session
Returns
-------
model : dict
Expand All @@ -138,7 +138,7 @@ def save_session(self, session_id, path=None, name=None, type=None, kernel_id=No
@gen.coroutine
def get_session(self, **kwargs):
"""Returns the model for a particular session.
Takes a keyword argument and searches for the value in the session
database, then returns the rest of the session's info.
Expand All @@ -151,7 +151,7 @@ def get_session(self, **kwargs):
Returns
-------
model : dict
returns a dictionary that includes all the information from the
returns a dictionary that includes all the information from the
session described by the kwarg.
"""
if not kwargs:
Expand Down Expand Up @@ -185,17 +185,17 @@ def get_session(self, **kwargs):
@gen.coroutine
def update_session(self, session_id, **kwargs):
"""Updates the values in the session database.
Changes the values of the session with the given session_id
with the values from the keyword arguments.
with the values from the keyword arguments.
Parameters
----------
session_id : str
a uuid that identifies a session in the sqlite3 database
**kwargs : str
the key must correspond to a column title in session database,
and the value replaces the current value in the session
and the value replaces the current value in the session
with session_id.
"""
yield maybe_future(self.get_session(session_id=session_id))
Expand Down
11 changes: 4 additions & 7 deletions jupyter_server/services/sessions/tests/test_sessionmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,22 @@
from jupyter_server.services.contents.manager import ContentsManager
from jupyter_server._tz import utcnow, isoformat


class DummyKernel(object):
def __init__(self, kernel_name='python'):
self.kernel_name = kernel_name

dummy_date = utcnow()
dummy_date_s = isoformat(dummy_date)


class DummyMKM(MappingKernelManager):
"""MappingKernelManager interface that doesn't start kernels, for testing"""

def __init__(self, *args, **kwargs):
super(DummyMKM, self).__init__(*args, **kwargs)
self.id_letters = iter(u'ABCDEFGHIJK')

def _new_id(self):
return next(self.id_letters)

def start_kernel(self, kernel_id=None, path=None, kernel_name='python', **kwargs):
kernel_id = kernel_id or self._new_id()
k = self._kernels[kernel_id] = DummyKernel(kernel_name=kernel_name)
Expand All @@ -43,7 +40,7 @@ def shutdown_kernel(self, kernel_id, now=False):


class TestSessionManager(TestCase):

def setUp(self):
self.sm = SessionManager(
kernel_manager=DummyMKM(),
Expand All @@ -62,7 +59,7 @@ def co_add():
sessions.append(session)
raise gen.Return(sessions)
return self.loop.run_sync(co_add)

def create_session(self, **kwargs):
return self.create_sessions(kwargs)[0]

Expand Down Expand Up @@ -201,7 +198,7 @@ def test_update_session(self):
}
}
self.assertEqual(model, expected)

def test_bad_update_session(self):
# try to update a session with a bad keyword ~ raise error
sm = self.sm
Expand Down
1 change: 0 additions & 1 deletion jupyter_server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ def _check_pid_posix(pid):

def maybe_future(obj):
"""Like tornado's deprecated gen.maybe_future
but more compatible with asyncio for recent versions
of tornado
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
'nbval', 'nose-exclude', 'selenium', 'pytest', 'pytest-cov'],
'test:sys_platform == "win32"': ['nose-exclude'],
},
python_requires='>=3.5',
python_requires = '>=3.5',
entry_points = {
'console_scripts': [
'jupyter-server = jupyter_server.serverapp:main',
Expand Down

0 comments on commit 56dadf5

Please sign in to comment.