Commit 49f6985
authored
feat: add support for async functions (GoogleCloudPlatform#364)
* feat: Introduce functions_framework.aio submodule that support async function execution.
* Remove httpx.
* Update pyproject.toml to include extra async package.
* Update test deps.
* Improve test coverage.
* Make linter happy.
* Fix test harness to support py37.
* Remove version filter in tox file.
* Remove dependency-groups in pyproject.toml for now.
* Use py3.8 compatible types.
* Fix more incompatibility with python38
* Pin cloudevent sdk to python37 compatible version.
* Fix more py37 incompatibility.
* fix: Prevent test_aio.py collection errors on Python 3.7
Add pytest_ignore_collect hook to skip test_aio.py entirely on Python 3.7
to prevent ImportError during test collection. The previous approach using
only pytest_collection_modifyitems was too late in the process - the error
occurred when pytest tried to import the module before skip markers could
be applied.
Both hooks are marked as safe to remove when Python 3.7 support is dropped.
* style: Apply black formatting to conftest.py
* fix: Use modern pytest collection_path parameter and return None
- Replace deprecated 'path' parameter with 'collection_path' in pytest_ignore_collect
- Return None instead of False to let pytest use default behavior
- This should fix the issue where pytest was collecting tests from .tox/.pkg/
* fix: Skip tests parametrized with None on Python 3.7
Simplify the check to just skip any test parametrized with None value.
On Python 3.7, create_asgi_app is always None due to the conditional
import, so this catches all async-related parametrized tests.
* fix: Replace asyncio.to_thread with Python 3.8 compatible code
Use asyncio.get_event_loop().run_in_executor() instead of
asyncio.to_thread() for Python 3.8 compatibility. Added TODO
comments to switch back when Python 3.8 support is dropped.
* fix: Improve async test detection for Python 3.7
- Use a list of async keywords (async, asgi, aio, starlette)
- Check for these keywords in test names, file paths, and parameters
- This catches more async-related tests including those with "aio" prefix
* fix: Handle Flask vs Starlette redirect behavior differences
- Remove unnecessary follow_redirects=True from Starlette TestClient
- Make test_http_function_request_url_empty_path aware of framework differences
- Starlette TestClient normalizes empty path "" to "/" while Flask preserves it
- Test now expects appropriate behavior for each framework
* fix: Exclude aio module from coverage on Python 3.7
Add special coverage configuration for Python 3.7 that excludes
the aio module since it requires Python 3.8+ due to Starlette
dependency. This prevents coverage failures on Python 3.7.
* fix: Simplify conftest.py.
* fix: Use full environment names for py37 coverage exclusion
The tox environment names in GitHub Actions include the OS suffix
(e.g., py37-ubuntu-22.04), so we need to match the full names.
* fix: Explicitly list each py37 environment for coverage exclusion
- List py37-ubuntu-22.04 and py37-macos-13 explicitly
- Place py37 settings before general windows-latest setting
- This should properly exclude aio module from coverage on Python 3.7
* fix: Add Python 3.7 specific coverage configuration
- Create .coveragerc-py37 to exclude aio module from coverage on Python 3.7
- Use --cov-config flag to specify this file for py37 environments only
- This prevents the aio module exclusion from affecting Python 3.8+ tests1 parent 37e0bf7 commit 49f6985
File tree
20 files changed
+1316
-172
lines changed- src/functions_framework/aio
- tests
- test_functions
- cloud_events
- decorators
- http_check_env
- http_request_check
- http_streaming
- http_trigger_sleep
- http_trigger
- http_with_import
20 files changed
+1316
-172
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
0 commit comments