uvicorn 0.32.1__py3-none-any.whl → 0.33.0__py3-none-any.whl
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.
- uvicorn/__init__.py +1 -1
- uvicorn/config.py +1 -1
- uvicorn/logging.py +1 -1
- uvicorn/supervisors/__init__.py +2 -9
- uvicorn/workers.py +1 -1
- {uvicorn-0.32.1.dist-info → uvicorn-0.33.0.dist-info}/METADATA +1 -1
- {uvicorn-0.32.1.dist-info → uvicorn-0.33.0.dist-info}/RECORD +10 -11
- uvicorn/supervisors/watchgodreload.py +0 -152
- {uvicorn-0.32.1.dist-info → uvicorn-0.33.0.dist-info}/WHEEL +0 -0
- {uvicorn-0.32.1.dist-info → uvicorn-0.33.0.dist-info}/entry_points.txt +0 -0
- {uvicorn-0.32.1.dist-info → uvicorn-0.33.0.dist-info}/licenses/LICENSE.md +0 -0
uvicorn/__init__.py
CHANGED
uvicorn/config.py
CHANGED
@@ -137,7 +137,7 @@ def resolve_reload_patterns(patterns_list: list[str], directories_list: list[str
|
|
137
137
|
# Special case for the .* pattern, otherwise this would only match
|
138
138
|
# hidden directories which is probably undesired
|
139
139
|
if pattern == ".*":
|
140
|
-
continue
|
140
|
+
continue # pragma: py-darwin
|
141
141
|
patterns.append(pattern)
|
142
142
|
if is_dir(Path(pattern)):
|
143
143
|
directories.append(Path(pattern))
|
uvicorn/logging.py
CHANGED
@@ -16,7 +16,7 @@ class ColourizedFormatter(logging.Formatter):
|
|
16
16
|
A custom log formatter class that:
|
17
17
|
|
18
18
|
* Outputs the LOG_LEVEL with an appropriate color.
|
19
|
-
* If a log call includes an `
|
19
|
+
* If a log call includes an `extra={"color_message": ...}` it will be used
|
20
20
|
for formatting the output, instead of the plain text message.
|
21
21
|
"""
|
22
22
|
|
uvicorn/supervisors/__init__.py
CHANGED
@@ -9,15 +9,8 @@ if TYPE_CHECKING:
|
|
9
9
|
ChangeReload: type[BaseReload]
|
10
10
|
else:
|
11
11
|
try:
|
12
|
-
from uvicorn.supervisors.watchfilesreload import
|
13
|
-
WatchFilesReload as ChangeReload,
|
14
|
-
)
|
12
|
+
from uvicorn.supervisors.watchfilesreload import WatchFilesReload as ChangeReload
|
15
13
|
except ImportError: # pragma: no cover
|
16
|
-
|
17
|
-
from uvicorn.supervisors.watchgodreload import (
|
18
|
-
WatchGodReload as ChangeReload,
|
19
|
-
)
|
20
|
-
except ImportError:
|
21
|
-
from uvicorn.supervisors.statreload import StatReload as ChangeReload
|
14
|
+
from uvicorn.supervisors.statreload import StatReload as ChangeReload
|
22
15
|
|
23
16
|
__all__ = ["Multiprocess", "ChangeReload"]
|
uvicorn/workers.py
CHANGED
@@ -11,7 +11,7 @@ from gunicorn.arbiter import Arbiter
|
|
11
11
|
from gunicorn.workers.base import Worker
|
12
12
|
|
13
13
|
from uvicorn.config import Config
|
14
|
-
from uvicorn.
|
14
|
+
from uvicorn.server import Server
|
15
15
|
|
16
16
|
warnings.warn(
|
17
17
|
"The `uvicorn.workers` module is deprecated. Please use `uvicorn-worker` package instead.\n"
|
@@ -1,14 +1,14 @@
|
|
1
|
-
uvicorn/__init__.py,sha256=
|
1
|
+
uvicorn/__init__.py,sha256=nQrfD4JNBDymcrFz6K1qe5h9zmUYcCjhNChn_ySwPPs,147
|
2
2
|
uvicorn/__main__.py,sha256=DQizy6nKP0ywhPpnCHgmRDYIMfcqZKVEzNIWQZjqtVQ,62
|
3
3
|
uvicorn/_subprocess.py,sha256=HbfRnsCkXyg7xCWVAWWzXQTeWlvLKfTlIF5wevFBkR4,2766
|
4
4
|
uvicorn/_types.py,sha256=TcUzCyKNq90ZX2Hxa6ce0juF558zLO_AyBB1XijnD2Y,7814
|
5
|
-
uvicorn/config.py,sha256=
|
5
|
+
uvicorn/config.py,sha256=GxC0lBCK0rLFJsloj_yqqS0NZ9QoBN89525b0V_yws4,20870
|
6
6
|
uvicorn/importer.py,sha256=nRt0QQ3qpi264-n_mR0l55C2ddM8nowTNzT1jsWaam8,1128
|
7
|
-
uvicorn/logging.py,sha256
|
7
|
+
uvicorn/logging.py,sha256=-eCE4nOJmFbtB9qfNJuEVNF0Y13LGUHqvFzemYT0PaQ,4235
|
8
8
|
uvicorn/main.py,sha256=iv6ptgDBnko0W-VkHs0e3I4UrF7_5sEZrntQNKJGFNY,16915
|
9
9
|
uvicorn/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
10
10
|
uvicorn/server.py,sha256=McDmVn0sBIVOzaCoKrp10oxaScD3tosoWhtsL1YldNo,13010
|
11
|
-
uvicorn/workers.py,sha256=
|
11
|
+
uvicorn/workers.py,sha256=7KGgGAapxGkGeXUcBGunOjSNdI9R44KCoWTGEAqAdfs,3895
|
12
12
|
uvicorn/lifespan/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
uvicorn/lifespan/off.py,sha256=nfI6qHAUo_8-BEXMBKoHQ9wUbsXrPaXLCbDSS0vKSr8,332
|
14
14
|
uvicorn/lifespan/on.py,sha256=1KYuFNNyQONIjtEHhKZAJp-OOokIyjj74wpGCGBv4lk,5184
|
@@ -32,14 +32,13 @@ uvicorn/protocols/websockets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
32
32
|
uvicorn/protocols/websockets/auto.py,sha256=kNP-h07ZzjA9dKRUd7MNO0J7xhRJ5xVBfit7wCbdB0A,574
|
33
33
|
uvicorn/protocols/websockets/websockets_impl.py,sha256=LV58OW3whQAd4iwbJl4R3iIod8myVYK3IhAn6F5VeZ4,15490
|
34
34
|
uvicorn/protocols/websockets/wsproto_impl.py,sha256=haJEXK82Ldu8_hz4NDxQ0KpPXa9vOi6pG6iDLoBDKjs,15341
|
35
|
-
uvicorn/supervisors/__init__.py,sha256=
|
35
|
+
uvicorn/supervisors/__init__.py,sha256=wT8eOEIqT1yWQgytZtv5taWMul7xoTIY0xm1m4oyPTw,507
|
36
36
|
uvicorn/supervisors/basereload.py,sha256=Hxezjgt_HXkOPVj-hJGH7uj0bZ3EhmwsmaOBc63ySoM,3831
|
37
37
|
uvicorn/supervisors/multiprocess.py,sha256=Opt0XvOUj1DIMXYwb4OlkJZxeh_RjweFnTmDPYItONw,7507
|
38
38
|
uvicorn/supervisors/statreload.py,sha256=gc-HUB44f811PvxD_ZIEQYenM7mWmhQQjYg7KKQ1c5o,1542
|
39
39
|
uvicorn/supervisors/watchfilesreload.py,sha256=41FGNMXPKrKvPr-5O8yRWg43l6OCBtapt39M-gpdk0E,3010
|
40
|
-
uvicorn/
|
41
|
-
uvicorn-0.
|
42
|
-
uvicorn-0.
|
43
|
-
uvicorn-0.
|
44
|
-
uvicorn-0.
|
45
|
-
uvicorn-0.32.1.dist-info/RECORD,,
|
40
|
+
uvicorn-0.33.0.dist-info/METADATA,sha256=qpnMGZS9iuwL1XUUHOvHeSAhzTL-aDsrko1-xB809pM,6584
|
41
|
+
uvicorn-0.33.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
42
|
+
uvicorn-0.33.0.dist-info/entry_points.txt,sha256=FW1w-hkc9QgwaGoovMvm0ZY73w_NcycWdGAUfDsNGxw,46
|
43
|
+
uvicorn-0.33.0.dist-info/licenses/LICENSE.md,sha256=7-Gs8-YvuZwoiw7HPlp3O3Jo70Mg_nV-qZQhTktjw3E,1526
|
44
|
+
uvicorn-0.33.0.dist-info/RECORD,,
|
@@ -1,152 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
import logging
|
4
|
-
import warnings
|
5
|
-
from pathlib import Path
|
6
|
-
from socket import socket
|
7
|
-
from typing import TYPE_CHECKING, Callable
|
8
|
-
|
9
|
-
from watchgod import DefaultWatcher
|
10
|
-
|
11
|
-
from uvicorn.config import Config
|
12
|
-
from uvicorn.supervisors.basereload import BaseReload
|
13
|
-
|
14
|
-
if TYPE_CHECKING:
|
15
|
-
import os
|
16
|
-
|
17
|
-
DirEntry = os.DirEntry[str]
|
18
|
-
|
19
|
-
logger = logging.getLogger("uvicorn.error")
|
20
|
-
|
21
|
-
|
22
|
-
class CustomWatcher(DefaultWatcher):
|
23
|
-
def __init__(self, root_path: Path, config: Config):
|
24
|
-
default_includes = ["*.py"]
|
25
|
-
self.includes = [default for default in default_includes if default not in config.reload_excludes]
|
26
|
-
self.includes.extend(config.reload_includes)
|
27
|
-
self.includes = list(set(self.includes))
|
28
|
-
|
29
|
-
default_excludes = [".*", ".py[cod]", ".sw.*", "~*"]
|
30
|
-
self.excludes = [default for default in default_excludes if default not in config.reload_includes]
|
31
|
-
self.excludes.extend(config.reload_excludes)
|
32
|
-
self.excludes = list(set(self.excludes))
|
33
|
-
|
34
|
-
self.watched_dirs: dict[str, bool] = {}
|
35
|
-
self.watched_files: dict[str, bool] = {}
|
36
|
-
self.dirs_includes = set(config.reload_dirs)
|
37
|
-
self.dirs_excludes = set(config.reload_dirs_excludes)
|
38
|
-
self.resolved_root = root_path
|
39
|
-
super().__init__(str(root_path))
|
40
|
-
|
41
|
-
def should_watch_file(self, entry: DirEntry) -> bool:
|
42
|
-
cached_result = self.watched_files.get(entry.path)
|
43
|
-
if cached_result is not None:
|
44
|
-
return cached_result
|
45
|
-
|
46
|
-
entry_path = Path(entry)
|
47
|
-
|
48
|
-
# cwd is not verified through should_watch_dir, so we need to verify here
|
49
|
-
if entry_path.parent == Path.cwd() and Path.cwd() not in self.dirs_includes:
|
50
|
-
self.watched_files[entry.path] = False
|
51
|
-
return False
|
52
|
-
for include_pattern in self.includes:
|
53
|
-
if str(entry_path).endswith(include_pattern):
|
54
|
-
self.watched_files[entry.path] = True
|
55
|
-
return True
|
56
|
-
if entry_path.match(include_pattern):
|
57
|
-
for exclude_pattern in self.excludes:
|
58
|
-
if entry_path.match(exclude_pattern):
|
59
|
-
self.watched_files[entry.path] = False
|
60
|
-
return False
|
61
|
-
self.watched_files[entry.path] = True
|
62
|
-
return True
|
63
|
-
self.watched_files[entry.path] = False
|
64
|
-
return False
|
65
|
-
|
66
|
-
def should_watch_dir(self, entry: DirEntry) -> bool:
|
67
|
-
cached_result = self.watched_dirs.get(entry.path)
|
68
|
-
if cached_result is not None:
|
69
|
-
return cached_result
|
70
|
-
|
71
|
-
entry_path = Path(entry)
|
72
|
-
|
73
|
-
if entry_path in self.dirs_excludes:
|
74
|
-
self.watched_dirs[entry.path] = False
|
75
|
-
return False
|
76
|
-
|
77
|
-
for exclude_pattern in self.excludes:
|
78
|
-
if entry_path.match(exclude_pattern):
|
79
|
-
is_watched = False
|
80
|
-
if entry_path in self.dirs_includes:
|
81
|
-
is_watched = True
|
82
|
-
|
83
|
-
for directory in self.dirs_includes:
|
84
|
-
if directory in entry_path.parents:
|
85
|
-
is_watched = True
|
86
|
-
|
87
|
-
if is_watched:
|
88
|
-
logger.debug(
|
89
|
-
"WatchGodReload detected a new excluded dir '%s' in '%s'; " "Adding to exclude list.",
|
90
|
-
entry_path.relative_to(self.resolved_root),
|
91
|
-
str(self.resolved_root),
|
92
|
-
)
|
93
|
-
self.watched_dirs[entry.path] = False
|
94
|
-
self.dirs_excludes.add(entry_path)
|
95
|
-
return False
|
96
|
-
|
97
|
-
if entry_path in self.dirs_includes:
|
98
|
-
self.watched_dirs[entry.path] = True
|
99
|
-
return True
|
100
|
-
|
101
|
-
for directory in self.dirs_includes:
|
102
|
-
if directory in entry_path.parents:
|
103
|
-
self.watched_dirs[entry.path] = True
|
104
|
-
return True
|
105
|
-
|
106
|
-
for include_pattern in self.includes:
|
107
|
-
if entry_path.match(include_pattern):
|
108
|
-
logger.info(
|
109
|
-
"WatchGodReload detected a new reload dir '%s' in '%s'; " "Adding to watch list.",
|
110
|
-
str(entry_path.relative_to(self.resolved_root)),
|
111
|
-
str(self.resolved_root),
|
112
|
-
)
|
113
|
-
self.dirs_includes.add(entry_path)
|
114
|
-
self.watched_dirs[entry.path] = True
|
115
|
-
return True
|
116
|
-
|
117
|
-
self.watched_dirs[entry.path] = False
|
118
|
-
return False
|
119
|
-
|
120
|
-
|
121
|
-
class WatchGodReload(BaseReload):
|
122
|
-
def __init__(
|
123
|
-
self,
|
124
|
-
config: Config,
|
125
|
-
target: Callable[[list[socket] | None], None],
|
126
|
-
sockets: list[socket],
|
127
|
-
) -> None:
|
128
|
-
warnings.warn(
|
129
|
-
'"watchgod" is deprecated, you should switch ' "to watchfiles (`pip install watchfiles`).",
|
130
|
-
DeprecationWarning,
|
131
|
-
)
|
132
|
-
super().__init__(config, target, sockets)
|
133
|
-
self.reloader_name = "WatchGod"
|
134
|
-
self.watchers = []
|
135
|
-
reload_dirs = []
|
136
|
-
for directory in config.reload_dirs:
|
137
|
-
if Path.cwd() not in directory.parents:
|
138
|
-
reload_dirs.append(directory)
|
139
|
-
if Path.cwd() not in reload_dirs:
|
140
|
-
reload_dirs.append(Path.cwd())
|
141
|
-
for w in reload_dirs:
|
142
|
-
self.watchers.append(CustomWatcher(w.resolve(), self.config))
|
143
|
-
|
144
|
-
def should_restart(self) -> list[Path] | None:
|
145
|
-
self.pause()
|
146
|
-
|
147
|
-
for watcher in self.watchers:
|
148
|
-
change = watcher.check()
|
149
|
-
if change != set():
|
150
|
-
return list({Path(c[1]) for c in change})
|
151
|
-
|
152
|
-
return None
|
File without changes
|
File without changes
|
File without changes
|