Skip to content

Commit f3f00df

Browse files
authored
Merge pull request #4454 from minrk/5.7.x
Backport PR #4449
2 parents ab64452 + d1e8d4d commit f3f00df

File tree

7 files changed

+74
-7
lines changed

7 files changed

+74
-7
lines changed

.travis.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ before_install:
4949
fi
5050
5151
install:
52-
- pip install --pre .[test]
52+
- pip install --pre .[test] $EXTRA_PIP
53+
- pip freeze
5354
- wget https://github.com/jgm/pandoc/releases/download/1.19.1/pandoc-1.19.1-1-amd64.deb && sudo dpkg -i pandoc-1.19.1-1-amd64.deb
5455

5556

@@ -96,10 +97,19 @@ matrix:
9697
env: GROUP=python
9798
- python: 3.5
9899
env: GROUP=python
99-
- python: "3.7-dev"
100+
- python: 3.7
101+
dist: xenial
100102
env: GROUP=python
101103
- python: 3.6
102104
env: GROUP=docs
105+
- python: 3.6
106+
env:
107+
- GROUP=python
108+
- EXTRA_PIP="tornado<5"
109+
- python: 2.7
110+
env:
111+
- GROUP=python
112+
- EXTRA_PIP="tornado<5"
103113

104114
after_success:
105115
- codecov

docs/source/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ We strongly recommend that you upgrade pip to version 9+ of pip before upgrading
2121
Use ``pip install pip --upgrade`` to upgrade pip. Check pip version with
2222
``pip --version``.
2323

24+
.. _release-5.7.5:
25+
26+
5.7.5
27+
-----
28+
29+
- Fix compatibility with tornado 6 (:ghpull:`4392`, :ghpull:`4449`).
30+
- Fix opening integer filedescriptor during startup on Python 2 (:ghpull:`4349`)
31+
- Fix compatibility with asynchronous `KernelManager.restart_kernel` methods (:ghpull:`4412`)
32+
2433
.. _release-5.7.4:
2534

2635
5.7.4

notebook/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
# Next beta/alpha/rc release: The version number for beta is X.Y.ZbN **without dots**.
1111

12-
version_info = (5, 7, 5, '.dev0')
12+
version_info = (5, 7, 5)
1313
__version__ = '.'.join(map(str, version_info[:3])) + ''.join(version_info[3:])

notebook/base/zmqhandlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def open(self, *args, **kwargs):
172172

173173
def send_ping(self):
174174
"""send a ping to keep the websocket alive"""
175-
if self.stream.closed() and self.ping_callback is not None:
175+
if self.ws_connection is None and self.ping_callback is not None:
176176
self.ping_callback.stop()
177177
return
178178

@@ -237,7 +237,7 @@ def _reserialize_reply(self, msg_or_list, channel=None):
237237
def _on_zmq_reply(self, stream, msg_list):
238238
# Sometimes this gets triggered when the on_close method is scheduled in the
239239
# eventloop but hasn't been called.
240-
if self.stream.closed() or stream.closed():
240+
if self.ws_connection is None or stream.closed():
241241
self.log.warning("zmq message arrived on closed channel")
242242
self.close()
243243
return

notebook/static/base/js/namespace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ define(function(){
7373
// tree
7474
jglobal('SessionList','tree/js/sessionlist');
7575

76-
Jupyter.version = "5.7.5.dev0";
76+
Jupyter.version = "5.7.5";
7777
Jupyter._target = '_blank';
7878
return Jupyter;
7979
});

notebook/utils.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,31 @@
1212
import sys
1313
from distutils.version import LooseVersion
1414

15+
try:
16+
from inspect import isawaitable
17+
except ImportError:
18+
def isawaitable(f):
19+
"""If isawaitable is undefined, nothing is awaitable"""
20+
return False
21+
22+
try:
23+
from concurrent.futures import Future as ConcurrentFuture
24+
except ImportError:
25+
class ConcurrentFuture:
26+
"""If concurrent.futures isn't importable, nothing will be a c.f.Future"""
27+
pass
28+
1529
try:
1630
from urllib.parse import quote, unquote, urlparse, urljoin
1731
from urllib.request import pathname2url
1832
except ImportError:
1933
from urllib import quote, unquote, pathname2url
2034
from urlparse import urlparse, urljoin
2135

36+
# tornado.concurrent.Future is asyncio.Future
37+
# in tornado >=5 with Python 3
38+
from tornado.concurrent import Future as TornadoFuture
39+
from tornado import gen
2240
from ipython_genutils import py3compat
2341

2442
# UF_HIDDEN is a stat flag not defined in the stat module.
@@ -306,3 +324,33 @@ def _check_pid_posix(pid):
306324
check_pid = _check_pid_win32
307325
else:
308326
check_pid = _check_pid_posix
327+
328+
329+
def maybe_future(obj):
330+
"""Like tornado's gen.maybe_future
331+
332+
but more compatible with asyncio for recent versions
333+
of tornado
334+
"""
335+
if isinstance(obj, TornadoFuture):
336+
return obj
337+
elif isawaitable(obj):
338+
return asyncio.ensure_future(obj)
339+
elif isinstance(obj, ConcurrentFuture):
340+
return asyncio.wrap_future(obj)
341+
else:
342+
# not awaitable, wrap scalar in future
343+
f = TornadoFuture()
344+
f.set_result(obj)
345+
return f
346+
347+
# monkeypatch tornado gen.maybe_future
348+
# on Python 3
349+
# TODO: remove monkeypatch after backporting smaller fix to 5.x
350+
try:
351+
import asyncio
352+
except ImportError:
353+
pass
354+
else:
355+
import tornado.gen
356+
tornado.gen.maybe_future = maybe_future

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
zip_safe = False,
8080
install_requires = [
8181
'jinja2',
82-
'tornado>=4, <6',
82+
'tornado>=4.1,<7',
8383
# pyzmq>=17 is not technically necessary,
8484
# but hopefully avoids incompatibilities with Tornado 5. April 2018
8585
'pyzmq>=17',

0 commit comments

Comments
 (0)