-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Implement web.run_app utility function #734
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
636b075
Add run_app()
asvetlov 0b8e831
Improve run_app code
asvetlov 918d820
Increase max timeout for connection shutdown
asvetlov 7670eee
Add shutdown_timeout parameter
asvetlov 2e4e4bb
Support ssl scheme
asvetlov 479e151
Merge branch 'master' into run_app
asvetlov 6f35b4d
Add tests for run_app
asvetlov c9b74c8
Add reference doc for run_app
asvetlov 6b5ed62
Use delayed call to stop loop
asvetlov 51267fb
Finish docs update for run_app
asvetlov a2b39a0
Fix flake error
asvetlov df0cb02
Merge branch 'master' into run_app
asvetlov 1b7f94c
Try to fix a test
asvetlov 0f17dca
Try to fix a test again
asvetlov 635599c
Skip failing test on Python 3.4
asvetlov 727393b
Fighting with failed test
asvetlov 69d30c0
Drop unused sys import
asvetlov 8460828
Work on failing test
asvetlov f418dca
Final commit with explanation why it was failed on Python 3.4
asvetlov 0733de2
Use Application.loop in run_app
asvetlov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,46 @@ | ||
import asyncio | ||
import ssl | ||
|
||
from unittest import mock | ||
from aiohttp import web | ||
|
||
|
||
def test_run_app_http(loop): | ||
loop = mock.Mock(spec=asyncio.AbstractEventLoop, wrap=loop) | ||
loop.call_later(0.01, loop.stop) | ||
|
||
app = web.Application(loop=loop) | ||
|
||
web.run_app(app) | ||
|
||
loop.close.assert_called_with() | ||
loop.create_server.assert_called_with(mock.ANY, '0.0.0.0', 8080, ssl=None) | ||
|
||
|
||
def test_run_app_https(loop): | ||
loop = mock.Mock(spec=asyncio.AbstractEventLoop, wrap=loop) | ||
loop.call_later(0.01, loop.stop) | ||
|
||
app = web.Application(loop=loop) | ||
|
||
ssl_context = ssl.create_default_context() | ||
|
||
web.run_app(app, ssl_context=ssl_context) | ||
|
||
loop.close.assert_called_with() | ||
loop.create_server.assert_called_with(mock.ANY, '0.0.0.0', 8443, | ||
ssl=ssl_context) | ||
|
||
|
||
def test_run_app_nondefault_host_port(loop, unused_port): | ||
port = unused_port() | ||
host = 'localhost' | ||
|
||
loop = mock.Mock(spec=asyncio.AbstractEventLoop, wrap=loop) | ||
loop.call_later(0.01, loop.stop) | ||
|
||
app = web.Application(loop=loop) | ||
|
||
web.run_app(app, host=host, port=port) | ||
|
||
loop.create_server.assert_called_with(mock.ANY, host, port, ssl=None) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should someone bind to public interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, read from end to top))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
::
for IPv6 (:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't follow.
Isn't knowledge of host/port info enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I already said -- I read diff from bottom to top) thought that you replaced '0.0.0.0' with localhost and bind to it)