1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
From f8c3e96df731eccda202e0dc909f0a51cdc41267 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Sat, 14 Jul 2018 12:21:50 +0200
Subject: [PATCH] dummyserver: Update for tornado-5 API changes
Tornado 5 has apparently removed support for multiple IOLoops,
and appropriately removed the io_loop parameter to the server class
in favor of using IOLoop.current(). Update the tests to use the latter.
The code remains compatible with tornado-4.
---
dummyserver/server.py | 9 +++++----
dummyserver/testcase.py | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/dummyserver/server.py b/dummyserver/server.py
index e1745b7..3ba5124 100755
--- a/dummyserver/server.py
+++ b/dummyserver/server.py
@@ -226,15 +226,16 @@ def bind_sockets(port, address=None, family=socket.AF_UNSPEC, backlog=128,
def run_tornado_app(app, io_loop, certs, scheme, host):
+ assert io_loop == tornado.ioloop.IOLoop.current()
+
# We can't use fromtimestamp(0) because of CPython issue 29097, so we'll
# just construct the datetime object directly.
app.last_req = datetime(1970, 1, 1)
if scheme == 'https':
- http_server = tornado.httpserver.HTTPServer(app, ssl_options=certs,
- io_loop=io_loop)
+ http_server = tornado.httpserver.HTTPServer(app, ssl_options=certs)
else:
- http_server = tornado.httpserver.HTTPServer(app, io_loop=io_loop)
+ http_server = tornado.httpserver.HTTPServer(app)
sockets = bind_sockets(None, address=host)
port = sockets[0].getsockname()[1]
@@ -268,7 +269,7 @@ if __name__ == '__main__':
from .testcase import TestingApp
host = '127.0.0.1'
- io_loop = tornado.ioloop.IOLoop()
+ io_loop = tornado.ioloop.IOLoop.current()
app = tornado.web.Application([(r".*", TestingApp)])
server, port = run_tornado_app(app, io_loop, None,
'http', host)
diff --git a/dummyserver/testcase.py b/dummyserver/testcase.py
index f73f028..d9ff8cf 100644
--- a/dummyserver/testcase.py
+++ b/dummyserver/testcase.py
@@ -124,7 +124,7 @@ class HTTPDummyServerTestCase(unittest.TestCase):
@classmethod
def _start_server(cls):
- cls.io_loop = ioloop.IOLoop()
+ cls.io_loop = ioloop.IOLoop.current()
app = web.Application([(r".*", TestingApp)])
cls.server, cls.port = run_tornado_app(app, cls.io_loop, cls.certs,
cls.scheme, cls.host)
@@ -170,7 +170,7 @@ class HTTPDummyProxyTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
- cls.io_loop = ioloop.IOLoop()
+ cls.io_loop = ioloop.IOLoop.current()
app = web.Application([(r'.*', TestingApp)])
cls.http_server, cls.http_port = run_tornado_app(
--
2.18.0
|