requirements: Upgrade to Tornado 6.

Fixes #8913.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-03-17 13:42:25 -07:00
committed by Alex Vandiver
parent f23bfe91c0
commit 7acb642fa5
11 changed files with 115 additions and 68 deletions

View File

@@ -246,7 +246,7 @@ class ClientDescriptor:
heartbeat_event = create_heartbeat_event()
self.add_event(heartbeat_event)
ioloop = tornado.ioloop.IOLoop.instance()
ioloop = tornado.ioloop.IOLoop.current()
interval = HEARTBEAT_MIN_FREQ_SECS + random.randint(0, 10)
if self.client_type_name != "API: heartbeat test":
self._timeout_handle = ioloop.call_later(interval, timeout_callback)
@@ -265,7 +265,7 @@ class ClientDescriptor:
self.current_handler_id = None
self.current_client_name = None
if self._timeout_handle is not None:
ioloop = tornado.ioloop.IOLoop.instance()
ioloop = tornado.ioloop.IOLoop.current()
ioloop.remove_timeout(self._timeout_handle)
self._timeout_handle = None
@@ -601,8 +601,6 @@ def send_restart_events(immediate: bool = False) -> None:
async def setup_event_queue(server: tornado.httpserver.HTTPServer, port: int) -> None:
ioloop = tornado.ioloop.IOLoop.instance()
if not settings.TEST_SUITE:
load_event_queues(port)
autoreload.add_reload_hook(lambda: dump_event_queues(port))
@@ -613,9 +611,7 @@ async def setup_event_queue(server: tornado.httpserver.HTTPServer, port: int) ->
pass
# Set up event queue garbage collection
pc = tornado.ioloop.PeriodicCallback(
lambda: gc_event_queues(port), EVENT_QUEUE_GC_FREQ_MSECS, ioloop
)
pc = tornado.ioloop.PeriodicCallback(lambda: gc_event_queues(port), EVENT_QUEUE_GC_FREQ_MSECS)
pc.start()
send_restart_events(immediate=settings.DEVELOPMENT)

View File

@@ -1,4 +1,3 @@
import asyncio
import logging
import urllib
import weakref
@@ -151,9 +150,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
async def get(self, *args: Any, **kwargs: Any) -> None:
request = self.convert_tornado_request_to_django_request()
response = await asyncio.ensure_future(
sync_to_async(lambda: self.get_response(request), thread_sensitive=True)()
)
response = await sync_to_async(lambda: self.get_response(request), thread_sensitive=True)()
try:
if hasattr(response, "asynchronous"):
@@ -184,7 +181,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
# the Django side; this triggers cleanup work like
# resetting the urlconf and any cache/database
# connections.
await asyncio.ensure_future(sync_to_async(response.close, thread_sensitive=True)())
await sync_to_async(response.close, thread_sensitive=True)()
async def head(self, *args: Any, **kwargs: Any) -> None:
await self.get(*args, **kwargs)
@@ -262,9 +259,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
res_type=result_dict["result"], data=result_dict, status=self.get_status()
)
response = await asyncio.ensure_future(
sync_to_async(lambda: self.get_response(request), thread_sensitive=True)()
)
response = await sync_to_async(lambda: self.get_response(request), thread_sensitive=True)()
try:
# Explicitly mark requests as varying by cookie, since the
# middleware will not have seen a session access
@@ -273,4 +268,4 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
self.write_django_response_as_tornado_response(response)
finally:
# Tell Django we're done processing this request
await asyncio.ensure_future(sync_to_async(response.close, thread_sensitive=True)())
await sync_to_async(response.close, thread_sensitive=True)()