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

feat: ASGI support #1573

Merged
merged 32 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
33a4941
feat: ASGI support
kgriffs Oct 4, 2019
290b223
refactor(asgi.Request): Replace the media prop with get_media()
kgriffs Dec 28, 2019
2feab63
test(asgi): Add additional type annotations
kgriffs Dec 31, 2019
01ead71
feat: Raise a TypeError when attempting to use an ASGI resource with …
kgriffs Dec 31, 2019
51def70
refactor: Do not require overriding serialize() and deserialize()
kgriffs Dec 31, 2019
0ab09c8
doc(asgi): Add async to ExampleHandler in docstring for add_lifespan_…
kgriffs Dec 31, 2019
75fdf86
doc(util.misc.http_status_to_code): Fix typo
kgriffs Dec 31, 2019
dd3ae16
test: Add pragma: nocover for while True loops
kgriffs Jan 2, 2020
b42abc7
chore: Remove cruft
kgriffs Jan 2, 2020
a906644
doc(falcon.testing.client): Fix typo in comment
kgriffs Jan 2, 2020
a73deb9
doc(sync): Work around codecov not detecting a branch correctly
kgriffs Jan 2, 2020
f1df033
feat(URLEncodedFormHandler): Add deserialize_async() method
kgriffs Jan 2, 2020
57b589a
doc(falcon.asgi.app): Fix typo in comment
kgriffs Jan 2, 2020
228cf3e
test: Uncomment tests
kgriffs Jan 2, 2020
2335bfd
refactor(test_response_media): Remove unused fixture params
kgriffs Jan 3, 2020
6978cdb
fix(asgi): Do not set content-length to zero for streamed response
kgriffs Jan 3, 2020
5a78a15
test(asgi): aiofiles
kgriffs Jan 3, 2020
2226831
refactor(asgi): Do not support the deprecated RequestOptions.auto_par…
kgriffs Jan 3, 2020
af6fca8
refactor: Isolate uvicorn tests to avoid intermittent hangs
kgriffs Jan 4, 2020
c14810c
test(ASGI): use PyPy-compatible uvicorn loop settings when on PyPy
vytas7 Jan 4, 2020
985e85b
test(ASGI): swap uvicorn options to make 'em look more natural, app l…
vytas7 Jan 4, 2020
9450c7f
style: fix a couple of trivial misspellings found when reviewing
vytas7 Jan 4, 2020
1a0f681
tests(asgi): Enable daphne server factory
kgriffs Jan 4, 2020
8aff45b
test(asgi): Rename test_asgi module
kgriffs Jan 4, 2020
d28a957
feat(media): Force content-length in base deserialize_async()
kgriffs Jan 4, 2020
01ca625
refactor: Merge lifespan handlers into middleware
kgriffs Jan 4, 2020
f8d2f71
chore: Enable verbose output on Travis
kgriffs Jan 4, 2020
6f183f4
fix: Daphne hang
kgriffs Jan 4, 2020
9ad0fdc
docs(asgi.response): fix docstring SSEent ==> SSEvent
vytas7 Jan 5, 2020
028f6fc
fix(CORSMiddleware): Missing coroutine version of process_response()
kgriffs Jan 8, 2020
19e726b
fix(CORSMiddleware): do not cythonize middleware classes
vytas7 Jan 8, 2020
5d5982b
Merge branch 'master' into asgi-final
vytas7 Jan 20, 2020
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*.py[cod]
.eggs
.installed.cfg
.mypy_cache
build
develop-eggs
dist
Expand All @@ -20,6 +21,7 @@ lib64
parts
sdist
var
pip-wheel-metadata

# Installer logs
pip-log.txt
Expand Down
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@ cache:

matrix:
include:
- python: pypy3.5-6.0
- python: pypy3.6-7.1.1
env: TOXENV=pypy3
- python: 3.8
env: TOXENV=pep8
- python: 3.8
env: TOXENV=pep8-examples
- python: 3.5
- python: 3.8
env: TOXENV=mypy
# NOTE(kgriffs): 3.5.2 is the default Python 3 version on Ubuntu 16.04
# so we pin to that for testing to make sure we are working around
# and quirks that were fixed in later micro versions.
- python: 3.5.2
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: 3.6
env: TOXENV=py36_cython
- python: 3.7
env: TOXENV=py37
- python: 3.8
env: TOXENV=py38
- python: 3.8
env: TOXENV=mypy
- python: 3.8
env: TOXENV=py38_cython
- python: 3.8
Expand All @@ -47,7 +52,7 @@ matrix:
- python: 3.8
env: TOXENV=check_vendored

script: tox
script: tox -- -v

notifications:
webhooks:
Expand Down
14 changes: 10 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,26 @@ Please note that all contributors and maintainers of this project are subject to

Before submitting a pull request, please ensure you have added or updated tests as appropriate, and that all existing tests still pass with your changes. Please also ensure that your coding style follows PEP 8.

You can check all this by running the following from within the Falcon project directory (requires Python 3.8 to be installed on your system):
You can check all this by running the following from within the Falcon project directory (requires Python 3.8 and 3.5 to be installed on your system):

```bash
$ tools/mintest.sh

```

You may also use Python 3.5, 3.6 or 3.7 if you don't have 3.8 installed on your system. Substitute "py35", "py36" or "py37" as appropriate. For example:
You may also use Python 3.6 or 3.7 if you don't have 3.8 installed on your system. Substitute "py36" or "py37" as appropriate. For example:


```bash
$ pip install -U tox coverage
$ rm -f .coverage.*
$ tox -e pep8 && tox -e py37 && tools/testing/combine_coverage.sh
$ tox -e pep8 && tox -e py35,py37 && tools/testing/combine_coverage.sh
```

If you are using pyenv, you will need to make sure both 3.8 and 3.5 are available in the current shell, e.g.:

```bash
$ pyenv shell 3.8.0 3.5.8
```

#### Reviews

Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ Installing it is as simple as:
Installing the Falcon wheel is a great way to get up and running
quickly in a development environment, but for an extra speed boost when
deploying your application in production, Falcon can compile itself with
Cython.
Cython. Note, however, that Cython is currently incompatible with
the falcon.asgi module.

The following commands tell pip to install Cython, and then to invoke
Falcon's ``setup.py``, which will in turn detect the presence of Cython
Expand Down
4 changes: 2 additions & 2 deletions docs/api/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Reference
simulate_request, simulate_get, simulate_head, simulate_post,
simulate_put, simulate_options, simulate_patch, simulate_delete,
TestClient, TestCase, SimpleTestResource, StartResponseMock,
capture_responder_args, rand_string, create_environ, redirected,
closed_wsgi_iterable
capture_responder_args, rand_string, create_environ, create_req,
create_asgi_req, redirected, closed_wsgi_iterable
3 changes: 2 additions & 1 deletion docs/user/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Installing it is as simple as:
Installing the Falcon wheel is a great way to get up and running
quickly in a development environment, but for an extra speed boost when
deploying your application in production, Falcon can compile itself with
Cython.
Cython. Note, however, that Cython is currently incompatible with
the falcon.asgi module.

The following commands tell pip to install Cython, and then to invoke
Falcon's ``setup.py``, which will in turn detect the presence of Cython
Expand Down
22 changes: 20 additions & 2 deletions falcon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Primary package for Falcon, the minimalist WSGI library.
"""Primary package for Falcon, the minimalist web API framework.

Falcon is a minimalist WSGI library for building speedy web APIs and app
Falcon is a minimalist web API framework for building speedy web APIs and app
backends. The `falcon` package can be used to directly access most of
the framework's classes, functions, and variables::

Expand All @@ -24,6 +24,9 @@

"""

import logging as _logging
import sys as _sys

# Hoist classes and functions into the falcon namespace
from falcon.version import __version__ # NOQA
from falcon.constants import * # NOQA
Expand All @@ -44,3 +47,18 @@
from falcon.hooks import before, after # NOQA
from falcon.request import Request, RequestOptions, Forwarded # NOQA
from falcon.response import Response, ResponseOptions # NOQA


ASGI_SUPPORTED = _sys.version_info.minor > 5
"""Set to ``True`` when ASGI is supported for the current Python version."""


# NOTE(kgriffs): Special singleton to be used internally whenever using
# None would be ambiguous.
_UNSET = object()


# NOTE(kgriffs): Only to be used internally on the rare occasion that we
# need to log something that we can't communicate any other way.
_logger = _logging.getLogger('falcon')
_logger.addHandler(_logging.NullHandler())
Loading