Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UrlDispatcher.add_route with partial coroutine handler #814

Merged
merged 2 commits into from Mar 12, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ def __init__(self, method, handler, *,
issubclass(handler, AbstractView)):
pass
else:
handler = asyncio.coroutine(handler)
@asyncio.coroutine
def handler_wrapper(*args, **kwargs):
result = handler(*args, **kwargs)
if asyncio.iscoroutine(result):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a check for asyncio.Future also.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to current documentation (for UrlDispatcher.add_route and Resource.add_route) handler should be callable which excludes asyncio.Future

result = yield from result
return result
handler = handler_wrapper

self._method = method
self._handler = handler
Expand Down