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

ASGI Support #532

Merged
merged 101 commits into from
Dec 4, 2019
Merged

ASGI Support #532

merged 101 commits into from
Dec 4, 2019

Conversation

masipcat
Copy link
Contributor

@masipcat masipcat commented Jun 15, 2019

@masipcat masipcat requested review from bloodbare and vangheem June 15, 2019 14:28
@masipcat masipcat mentioned this pull request Jun 15, 2019
@dmanchon
Copy link
Member

TODO:

  • get rid of starlette.websockets.WebSocket dependency
  • move WebSocketSession to async_asgi_testclient
  • improve the IRequest interface
  • AsgiStreamReader is not able to support HTTP2 should be reimplemented correctly

requirements.txt Outdated Show resolved Hide resolved
@bloodbare
Copy link
Member

@masipcat that holds the merge until uvloops merge is done?

@masipcat
Copy link
Contributor Author

@bloodbare The problem with uvloop is that the official release is built with Cython <0.29.12 (doesn't support python 3.8) and is distributed with binaries (python wheels). Building uvloop from source using Cython 0.29.13 works without any other change.

So, I don't think we need to wait, but it's up to you ;)

docs/source/training/extending/websockets.md Outdated Show resolved Hide resolved
guillotina/asgi.py Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
@vangheem
Copy link
Member

Thoughts on git+https://github.com/dmontagu/uvloop@patch-1? Maybe not depend on 3.8 yet?

@masipcat
Copy link
Contributor Author

I removed python 3.8 on travis and removed the git+https... in the requirements.

@masipcat
Copy link
Contributor Author

TODO: find the best way to make these tests work, beucase the async_asgi_testclient doesn't start a http server to run the tests, it calls the app directly...

async def test_requester_with_default_settings(container_requester):
async with container_requester as requester:
assert requester.server.host == "127.0.0.1"
@pytest.mark.app_settings({"test_server_settings": {"host": "0.0.0.0", "port": 8080}})
async def test_requester_with_custom_settings(container_requester):
async with container_requester as requester:
assert requester.server.host == "0.0.0.0"
assert requester.server.port == 8080

@masipcat
Copy link
Contributor Author

@bloodbare @vangheem all tests passing again.

TODO:

  • investigate if uvicorn/hypercorn reuse asyncio task (with http1.1 + keep alive)

@masipcat
Copy link
Contributor Author

masipcat commented Dec 4, 2019

@bloodbare @vangheem all tests passing again.

TODO:

* investigate if uvicorn/hypercorn reuse asyncio task (with http1.1 + keep alive)

I checked uvicorn and hypercorn implemetantions and I found that both are creating a task for each request, as you can see here: https://github.com/encode/uvicorn/blob/master/uvicorn/protocols/http/h11_impl.py#L234. Also, I think the H11Protocol is called for each request (or for each session if it has keep_alive) so, it reuses the task of the H11Protocol but creates a task for each request.

@vangheem
Copy link
Member

vangheem commented Dec 4, 2019

@bloodbare I'm about to push the merge button after tests pass here.

@masipcat is it okay if I squash all the commits?

@masipcat
Copy link
Contributor Author

masipcat commented Dec 4, 2019

@masipcat is it okay if I squash all the commits?

@vangheem yes!

@vangheem vangheem merged commit fd73ae1 into master Dec 4, 2019
@vangheem vangheem deleted the asgi-support branch December 4, 2019 20:51
@bloodbare
Copy link
Member

💪👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants