Merge pull request #9 from noone234/fix-async-coro

Fix async coroutine execution in HandlerMixin.prepare()
This commit is contained in:
Andrew Rabert 2019-12-18 13:05:23 -05:00 committed by GitHub
commit c48b1c37d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 6 deletions

View file

@ -1,6 +1,11 @@
Version History
---------------
`3.0.0`_ (18-Dec-2019)
~~~~~~~~~~~~~~~~~~~~~~
- Dropped support for Tornado 4
- Fixed support for async prepare in superclasses of ``HandlerMixin``
`2.0.1`_ (18-Mar-2019)
~~~~~~~~~~~~~~~~~~~~~~
- Add support for Tornado 6
@ -21,6 +26,7 @@ Version History
~~~~~~~~~~~~~~~~~~~~~~
- Adds ``sprockets.mixins.correlation.HandlerMixin``
.. _`3.0.0`: https://github.com/sprockets/sprockets.mixins.correlation/compare/3.0.0...2.0.1
.. _`2.0.1`: https://github.com/sprockets/sprockets.mixins.correlation/compare/2.0.0...2.0.1
.. _`2.0.0`: https://github.com/sprockets/sprockets.mixins.correlation/compare/1.0.2...2.0.0
.. _`1.0.2`: https://github.com/sprockets/sprockets.mixins.correlation/compare/1.0.1...1.0.2

View file

@ -1 +1 @@
tornado>=4.3,<7
tornado>=5,<7

View file

@ -7,5 +7,5 @@ except ImportError:
raise ImportError
version_info = (2, 0, 1)
version_info = (3, 0, 0)
__version__ = '.'.join(str(v) for v in version_info[:3])

View file

@ -1,6 +1,7 @@
import asyncio
import uuid
from tornado import concurrent, log
from tornado import log
class HandlerMixin(object):
@ -45,9 +46,9 @@ class HandlerMixin(object):
# Here we want to copy an incoming Correlation-ID header if
# one exists. We also want to set it in the outgoing response
# which the property setter does for us.
maybe_future = super(HandlerMixin, self).prepare()
if concurrent.is_future(maybe_future):
await maybe_future
maybe_coro = super(HandlerMixin, self).prepare()
if asyncio.iscoroutine(maybe_coro):
await maybe_coro
correlation_id = self.get_request_header(self.__header_name, None)
if correlation_id is not None: