Skip to content

Commit a0640b3

Browse files
committed
more work on removing asyncio patch
1 parent 480d6d6 commit a0640b3

File tree

2 files changed

+8
-62
lines changed

2 files changed

+8
-62
lines changed

jupyter_server/serverapp.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,32 +1604,12 @@ def init_httpserver(self):
16041604

16051605
@staticmethod
16061606
def _init_asyncio_patch():
1607-
return
1608-
# """set default asyncio policy to be compatible with tornado
1609-
# Tornado 6 (at least) is not compatible with the default
1610-
# asyncio implementation on Windows
1611-
# Pick the older SelectorEventLoopPolicy on Windows
1612-
# if the known-incompatible default policy is in use.
1613-
# do this as early as possible to make it a low priority and overrideable
1614-
# ref: https://github.com/tornadoweb/tornado/issues/2608
1615-
# FIXME: if/when tornado supports the defaults in asyncio,
1616-
# remove and bump tornado requirement for py38
1617-
# """
1618-
# if sys.platform.startswith("win") and sys.version_info >= (3, 8):
1619-
# import asyncio
1620-
# try:
1621-
# from asyncio import (
1622-
# WindowsProactorEventLoopPolicy,
1623-
# WindowsSelectorEventLoopPolicy,
1624-
# )
1625-
# except ImportError:
1626-
# pass
1627-
# # not affected
1628-
# else:
1629-
# if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
1630-
# # WindowsProactorEventLoopPolicy is not compatible with tornado 6
1631-
# # fallback to the pre-3.8 default of Selector
1632-
# asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
1607+
"""no longer needed with tornado 6.1"""
1608+
warnings.warn(
1609+
"""ServerApp._init_asyncio_patch called, and is longer needed for """
1610+
"""tornado 6.1+, and will be removed in a future release.""",
1611+
DeprecationWarning
1612+
)
16331613

16341614
@catch_config_error
16351615
def initialize(self, argv=None, find_extensions=True, new_httpserver=True):
@@ -1649,7 +1629,6 @@ def initialize(self, argv=None, find_extensions=True, new_httpserver=True):
16491629
If True, a tornado HTTPServer instance will be created and configured for the Server Web
16501630
Application. This will set the http_server attribute of this class.
16511631
"""
1652-
self._init_asyncio_patch()
16531632
# Parse command line, load ServerApp config files,
16541633
# and update ServerApp config.
16551634
super(ServerApp, self).initialize(argv)

tests/test_files.py

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,14 @@ def maybe_hidden(request):
2121
return request.param
2222

2323

24-
25-
TIMEOUTS = dict(
26-
# default is 20.0
27-
connect_timeout=0.0,
28-
# needs patch below
29-
request_timeout=0.0
30-
)
31-
32-
# HACK: shouldn't be overloading this
33-
34-
from jupyter_server.utils import url_path_join
35-
import urllib.parse
36-
from tornado.escape import url_escape
37-
38-
@pytest.fixture
39-
def jp_fetch(jp_serverapp, http_server_client, jp_auth_header, jp_base_url):
40-
def client_fetch(*parts, headers={}, params={}, **kwargs):
41-
# Handle URL strings
42-
path_url = url_escape(url_path_join(jp_base_url, *parts), plus=False)
43-
params_url = urllib.parse.urlencode(params)
44-
url = path_url + "?" + params_url
45-
# Add auth keys to header
46-
headers.update(jp_auth_header)
47-
# Make request.
48-
kwargs.setdefault("request_timeout", 20.0)
49-
return http_server_client.fetch(
50-
url, headers=headers, **kwargs
51-
)
52-
return client_fetch
53-
54-
# /HACK
55-
5624
async def fetch_expect_200(jp_fetch, *path_parts):
57-
r = await jp_fetch('files', *path_parts, method='GET', **TIMEOUTS)
25+
r = await jp_fetch('files', *path_parts, method='GET')
5826
assert (r.body.decode() == path_parts[-1]), (path_parts, r.body)
5927

6028

6129
async def fetch_expect_404(jp_fetch, *path_parts):
6230
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
63-
r = await jp_fetch('files', *path_parts, method='GET', **TIMEOUTS)
64-
print(r.body)
31+
r = await jp_fetch('files', *path_parts, method='GET')
6532
assert expected_http_error(e, 404), [path_parts, e]
6633

6734

0 commit comments

Comments
 (0)