make Sanic.create_server return an asyncio.Server

- adding 2 new parameters to Sanic.create_server:
   * return_asyncio_server=False - defines whether there's
     a need to return an asyncio.Server or run it right away
   * asyncio_server_kwargs=None - for python 3.7 uvloop doesn't
     support all necessary features like "start_serving",
     so, in order to make sanic work well with asyncio from 3.7
     there's a need to introduce generic way for passing
     kwargs for "loop.create_server"

Closes: #1469
This commit is contained in:
Denis Makogon
2019-01-15 13:38:47 +02:00
parent 2af229eb1a
commit 391639210e
3 changed files with 26 additions and 3 deletions

View File

@@ -17,6 +17,11 @@ def test_app_loop_running(app):
assert response.text == "pass"
def test_create_asyncio_server(app):
asyncio_srv = app.create_server(return_asyncio_server=True)
assert isinstance(asyncio_srv, asyncio.AbstractServer)
def test_app_loop_not_running(app):
with pytest.raises(SanicException) as excinfo:
app.loop