muffin 0.93.5__tar.gz → 0.94.2__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.
Files changed (26) hide show
  1. {muffin-0.93.5/muffin.egg-info → muffin-0.94.2}/PKG-INFO +1 -1
  2. {muffin-0.93.5 → muffin-0.94.2}/muffin/app.py +15 -6
  3. {muffin-0.93.5 → muffin-0.94.2/muffin.egg-info}/PKG-INFO +1 -1
  4. {muffin-0.93.5 → muffin-0.94.2}/pyproject.toml +1 -1
  5. {muffin-0.93.5 → muffin-0.94.2}/LICENSE +0 -0
  6. {muffin-0.93.5 → muffin-0.94.2}/MANIFEST.in +0 -0
  7. {muffin-0.93.5 → muffin-0.94.2}/README.rst +0 -0
  8. {muffin-0.93.5 → muffin-0.94.2}/muffin/__init__.py +0 -0
  9. {muffin-0.93.5 → muffin-0.94.2}/muffin/constants.py +0 -0
  10. {muffin-0.93.5 → muffin-0.94.2}/muffin/errors.py +0 -0
  11. {muffin-0.93.5 → muffin-0.94.2}/muffin/handler.py +0 -0
  12. {muffin-0.93.5 → muffin-0.94.2}/muffin/manage.py +0 -0
  13. {muffin-0.93.5 → muffin-0.94.2}/muffin/plugins.py +0 -0
  14. {muffin-0.93.5 → muffin-0.94.2}/muffin/py.typed +0 -0
  15. {muffin-0.93.5 → muffin-0.94.2}/muffin/pytest.py +0 -0
  16. {muffin-0.93.5 → muffin-0.94.2}/muffin/types.py +0 -0
  17. {muffin-0.93.5 → muffin-0.94.2}/muffin/utils.py +0 -0
  18. {muffin-0.93.5 → muffin-0.94.2}/muffin.egg-info/SOURCES.txt +0 -0
  19. {muffin-0.93.5 → muffin-0.94.2}/muffin.egg-info/dependency_links.txt +0 -0
  20. {muffin-0.93.5 → muffin-0.94.2}/muffin.egg-info/entry_points.txt +0 -0
  21. {muffin-0.93.5 → muffin-0.94.2}/muffin.egg-info/requires.txt +0 -0
  22. {muffin-0.93.5 → muffin-0.94.2}/muffin.egg-info/top_level.txt +0 -0
  23. {muffin-0.93.5 → muffin-0.94.2}/setup.cfg +0 -0
  24. {muffin-0.93.5 → muffin-0.94.2}/tests/test_application.py +0 -0
  25. {muffin-0.93.5 → muffin-0.94.2}/tests/test_base.py +0 -0
  26. {muffin-0.93.5 → muffin-0.94.2}/tests/test_pytest.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: muffin
3
- Version: 0.93.5
3
+ Version: 0.94.2
4
4
  Summary: Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)
5
5
  Author-email: Kirill Klenov <horneds@gmail.com>
6
6
  License: MIT License
@@ -2,12 +2,13 @@
2
2
  from __future__ import annotations
3
3
 
4
4
  import logging
5
+ from contextvars import ContextVar
5
6
  from inspect import isawaitable, stack
6
7
  from logging.config import dictConfig
7
- from typing import TYPE_CHECKING, Any, Dict, Mapping, Union
8
+ from typing import TYPE_CHECKING, Any, Dict, Final, Mapping, Union
8
9
 
9
10
  from asgi_tools import App as BaseApp
10
- from asgi_tools.middleware import BACKGROUND_TASK
11
+ from asgi_tools._compat import aio_wait
11
12
  from modconfig import Config
12
13
 
13
14
  from muffin.constants import CONFIG_ENV_VARIABLE
@@ -21,6 +22,11 @@ if TYPE_CHECKING:
21
22
 
22
23
  from muffin.plugins import BasePlugin
23
24
 
25
+ BACKGROUND_TASK: Final["ContextVar[set[Awaitable] | None]"] = ContextVar(
26
+ "background_tasks",
27
+ default=None,
28
+ )
29
+
24
30
 
25
31
  class Application(BaseApp):
26
32
  """The Muffin Application."""
@@ -103,9 +109,9 @@ class Application(BaseApp):
103
109
  ):
104
110
  """Support background tasks."""
105
111
  await self.lifespan(scope, receive, send)
106
- bgtask = BACKGROUND_TASK.get()
107
- if bgtask is not None:
108
- await bgtask
112
+ bgtasks = BACKGROUND_TASK.get()
113
+ if bgtasks is not None:
114
+ await aio_wait(*bgtasks)
109
115
  BACKGROUND_TASK.set(None)
110
116
 
111
117
  def import_submodules(self, *submodules: str):
@@ -153,4 +159,7 @@ class Application(BaseApp):
153
159
  if not isawaitable(task):
154
160
  raise TypeError("Task must be awaitable") # noqa: TRY003
155
161
 
156
- BACKGROUND_TASK.set(task)
162
+ scheduled = BACKGROUND_TASK.get() or set()
163
+ scheduled.add(task)
164
+
165
+ BACKGROUND_TASK.set(scheduled)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: muffin
3
- Version: 0.93.5
3
+ Version: 0.94.2
4
4
  Summary: Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)
5
5
  Author-email: Kirill Klenov <horneds@gmail.com>
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "muffin"
3
- version = "0.93.5"
3
+ version = "0.94.2"
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"
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