muffin 0.93.3__tar.gz → 0.93.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {muffin-0.93.3/muffin.egg-info → muffin-0.93.5}/PKG-INFO +1 -1
- {muffin-0.93.3 → muffin-0.93.5}/muffin/app.py +7 -8
- {muffin-0.93.3 → muffin-0.93.5}/muffin/handler.py +5 -5
- {muffin-0.93.3 → muffin-0.93.5/muffin.egg-info}/PKG-INFO +1 -1
- {muffin-0.93.3 → muffin-0.93.5}/muffin.egg-info/requires.txt +1 -1
- {muffin-0.93.3 → muffin-0.93.5}/pyproject.toml +2 -4
- {muffin-0.93.3 → muffin-0.93.5}/LICENSE +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/MANIFEST.in +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/README.rst +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/__init__.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/constants.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/errors.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/manage.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/plugins.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/py.typed +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/pytest.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/types.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin/utils.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin.egg-info/SOURCES.txt +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin.egg-info/dependency_links.txt +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin.egg-info/entry_points.txt +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/muffin.egg-info/top_level.txt +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/setup.cfg +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/tests/test_application.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/tests/test_base.py +0 -0
- {muffin-0.93.3 → muffin-0.93.5}/tests/test_pytest.py +0 -0
@@ -2,7 +2,6 @@
|
|
2
2
|
from __future__ import annotations
|
3
3
|
|
4
4
|
import logging
|
5
|
-
from contextvars import ContextVar
|
6
5
|
from inspect import isawaitable, stack
|
7
6
|
from logging.config import dictConfig
|
8
7
|
from typing import TYPE_CHECKING, Any, Dict, Mapping, Union
|
@@ -23,9 +22,6 @@ if TYPE_CHECKING:
|
|
23
22
|
from muffin.plugins import BasePlugin
|
24
23
|
|
25
24
|
|
26
|
-
background_task = ContextVar("background_task", default=None)
|
27
|
-
|
28
|
-
|
29
25
|
class Application(BaseApp):
|
30
26
|
"""The Muffin Application."""
|
31
27
|
|
@@ -108,7 +104,7 @@ class Application(BaseApp):
|
|
108
104
|
"""Support background tasks."""
|
109
105
|
await self.lifespan(scope, receive, send)
|
110
106
|
bgtask = BACKGROUND_TASK.get()
|
111
|
-
if bgtask is not None
|
107
|
+
if bgtask is not None:
|
112
108
|
await bgtask
|
113
109
|
BACKGROUND_TASK.set(None)
|
114
110
|
|
@@ -129,8 +125,8 @@ class Application(BaseApp):
|
|
129
125
|
package_name = parent_frame.f_locals["__name__"]
|
130
126
|
return import_submodules(package_name, *submodules)
|
131
127
|
|
132
|
-
def
|
133
|
-
"""Await the given awaitable after the
|
128
|
+
def run_after_response(self, task: Awaitable):
|
129
|
+
"""Await the given awaitable after the response is completed.
|
134
130
|
|
135
131
|
.. code-block:: python
|
136
132
|
|
@@ -147,11 +143,14 @@ class Application(BaseApp):
|
|
147
143
|
async def send(request):
|
148
144
|
|
149
145
|
# Schedule any awaitable for later execution
|
150
|
-
app.
|
146
|
+
app.run_after_response(send_email('user@email.com', 'Hello from Muffin!'))
|
151
147
|
|
152
148
|
# Return response to a client immediately
|
153
149
|
# The task will be executed after the response is sent
|
154
150
|
return "OK"
|
155
151
|
|
156
152
|
"""
|
153
|
+
if not isawaitable(task):
|
154
|
+
raise TypeError("Task must be awaitable") # noqa: TRY003
|
155
|
+
|
157
156
|
BACKGROUND_TASK.set(task)
|
@@ -15,21 +15,21 @@ if TYPE_CHECKING:
|
|
15
15
|
from http_router import Router
|
16
16
|
|
17
17
|
|
18
|
-
|
19
18
|
class HandlerMeta(type):
|
20
19
|
"""Prepare handlers."""
|
21
20
|
|
22
21
|
def __new__(
|
23
|
-
mcs: Type,
|
22
|
+
mcs: Type,
|
23
|
+
name: str,
|
24
|
+
bases: Tuple[type],
|
25
|
+
params: Dict[str, Any],
|
24
26
|
) -> Type["Handler"]:
|
25
27
|
"""Prepare a Handler Class."""
|
26
28
|
cls: Type[Handler] = super().__new__(mcs, name, bases, params)
|
27
29
|
|
28
30
|
# Ensure that the class methods are exist and iterable
|
29
31
|
if not cls.methods:
|
30
|
-
cls.methods = [
|
31
|
-
method for method in HTTP_METHODS if method.lower() in cls.__dict__
|
32
|
-
]
|
32
|
+
cls.methods = [method for method in HTTP_METHODS if method.lower() in cls.__dict__]
|
33
33
|
|
34
34
|
elif isinstance(cls.methods, str):
|
35
35
|
cls.methods = [cls.methods]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "muffin"
|
3
|
-
version = "0.93.
|
3
|
+
version = "0.93.5"
|
4
4
|
description = "Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)"
|
5
5
|
readme = "README.rst"
|
6
6
|
requires-python = ">=3.8"
|
@@ -23,7 +23,7 @@ classifiers = [
|
|
23
23
|
"Framework :: Trio",
|
24
24
|
]
|
25
25
|
dependencies = [
|
26
|
-
"asgi-tools >= 0.
|
26
|
+
"asgi-tools >= 0.73.0",
|
27
27
|
"modconfig >= 1.2.1",
|
28
28
|
"ujson; implementation_name == 'cpython'",
|
29
29
|
]
|
@@ -66,8 +66,6 @@ muffin_app = "tests:app"
|
|
66
66
|
|
67
67
|
[tool.mypy]
|
68
68
|
packages = ["muffin"]
|
69
|
-
install_types = true
|
70
|
-
non_interactive = true
|
71
69
|
ignore_missing_imports = true
|
72
70
|
|
73
71
|
[tool.tox]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|