-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HH-102457 Handle exceptions in futures
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |