Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/HH-102457' into EXP-36855
Browse files Browse the repository at this point in the history
  • Loading branch information
HH ReleaseBot committed Jan 10, 2020
2 parents c40ed5b + e7becef commit 5133d60
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
9 changes: 7 additions & 2 deletions frontik/futures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
import logging
from functools import wraps
from functools import wraps, partial

from tornado.ioloop import IOLoop
from tornado.concurrent import Future
Expand Down Expand Up @@ -102,8 +102,13 @@ def new_cb(*args, **kwargs):

return new_cb

@staticmethod
def _handle_future(callback, future):
future.result()
callback()

def add_future(self, future):
IOLoop.current().add_future(future, self.add_notification())
IOLoop.current().add_future(future, partial(self._handle_future, self.add_notification()))
return future

def get_finish_future(self):
Expand Down
17 changes: 17 additions & 0 deletions tests/projects/test_app/pages/error_yield.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from tornado import gen

import frontik.handler


@gen.coroutine
def some_async_function(handler):
yield handler.post_url(handler.request.host, handler.request.path)
return 1 / 0


class Page(frontik.handler.PageHandler):
def get_page(self):
self.finish_group.add_future(some_async_function(self))

def post_page(self):
self.text = 'result'
9 changes: 9 additions & 0 deletions tests/test_yield_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import unittest

from .instances import frontik_test_app


class TestHandler(unittest.TestCase):
def test_error_in_yield(self):
response = frontik_test_app.get_page('error_yield')
self.assertEqual(response.status_code, 500)

0 comments on commit 5133d60

Please sign in to comment.