From 2ae97fdf35bc2b3270eeff899f0f4f3a7aaf54a0 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 18 Mar 2018 17:12:28 -0400 Subject: [PATCH] auth: Accept native coroutines in _oauth_get_user_future --- tornado/auth.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tornado/auth.py b/tornado/auth.py index 12cf37d8..0f9e2a54 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -502,7 +502,9 @@ class OAuthMixin(object): return access_token = _oauth_parse_response(response.body) - self._oauth_get_user_future(access_token).add_done_callback( + fut = self._oauth_get_user_future(access_token) + fut = gen.convert_yielded(fut) + fut.add_done_callback( functools.partial(self._on_oauth_get_user, access_token, future)) def _oauth_consumer_token(self): @@ -528,6 +530,10 @@ class OAuthMixin(object): For backwards compatibility, the callback-based ``_oauth_get_user`` method is also supported. + .. versionchanged:: 5.1 + + Subclasses may also define this method with ``async def``. + .. deprecated:: 5.1 The ``_oauth_get_user`` fallback is deprecated and support for it -- GitLab