uvicorn 0.32.1__py3-none-any.whl → 0.34.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/_types.py +5 -17
- uvicorn/config.py +3 -2
- uvicorn/logging.py +1 -1
- uvicorn/middleware/wsgi.py +1 -1
- uvicorn/protocols/websockets/websockets_impl.py +2 -1
- uvicorn/protocols/websockets/wsproto_impl.py +1 -0
- uvicorn/server.py +3 -5
- uvicorn/supervisors/__init__.py +2 -9
- uvicorn/supervisors/basereload.py +2 -1
- uvicorn/supervisors/statreload.py +2 -1
- uvicorn/workers.py +1 -1
- {uvicorn-0.32.1.dist-info → uvicorn-0.34.0.dist-info}/METADATA +2 -3
- {uvicorn-0.32.1.dist-info → uvicorn-0.34.0.dist-info}/RECORD +17 -18
- uvicorn/supervisors/watchgodreload.py +0 -152
- {uvicorn-0.32.1.dist-info → uvicorn-0.34.0.dist-info}/WHEEL +0 -0
- {uvicorn-0.32.1.dist-info → uvicorn-0.34.0.dist-info}/entry_points.txt +0 -0
- {uvicorn-0.32.1.dist-info → uvicorn-0.34.0.dist-info}/licenses/LICENSE.md +0 -0
uvicorn/__init__.py
CHANGED
uvicorn/_types.py
CHANGED
@@ -32,20 +32,8 @@ from __future__ import annotations
|
|
32
32
|
|
33
33
|
import sys
|
34
34
|
import types
|
35
|
-
from
|
36
|
-
|
37
|
-
Awaitable,
|
38
|
-
Callable,
|
39
|
-
Iterable,
|
40
|
-
Literal,
|
41
|
-
MutableMapping,
|
42
|
-
Optional,
|
43
|
-
Protocol,
|
44
|
-
Tuple,
|
45
|
-
Type,
|
46
|
-
TypedDict,
|
47
|
-
Union,
|
48
|
-
)
|
35
|
+
from collections.abc import Awaitable, Iterable, MutableMapping
|
36
|
+
from typing import Any, Callable, Literal, Optional, Protocol, TypedDict, Union
|
49
37
|
|
50
38
|
if sys.version_info >= (3, 11): # pragma: py-lt-311
|
51
39
|
from typing import NotRequired
|
@@ -54,8 +42,8 @@ else: # pragma: py-gte-311
|
|
54
42
|
|
55
43
|
# WSGI
|
56
44
|
Environ = MutableMapping[str, Any]
|
57
|
-
ExcInfo =
|
58
|
-
StartResponse = Callable[[str, Iterable[
|
45
|
+
ExcInfo = tuple[type[BaseException], BaseException, Optional[types.TracebackType]]
|
46
|
+
StartResponse = Callable[[str, Iterable[tuple[str, str]], Optional[ExcInfo]], None]
|
59
47
|
WSGIApp = Callable[[Environ, StartResponse], Union[Iterable[bytes], BaseException]]
|
60
48
|
|
61
49
|
|
@@ -281,7 +269,7 @@ class ASGI2Protocol(Protocol):
|
|
281
269
|
async def __call__(self, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None: ... # pragma: no cover
|
282
270
|
|
283
271
|
|
284
|
-
ASGI2Application =
|
272
|
+
ASGI2Application = type[ASGI2Protocol]
|
285
273
|
ASGI3Application = Callable[
|
286
274
|
[
|
287
275
|
Scope,
|
uvicorn/config.py
CHANGED
@@ -9,9 +9,10 @@ import os
|
|
9
9
|
import socket
|
10
10
|
import ssl
|
11
11
|
import sys
|
12
|
+
from collections.abc import Awaitable
|
12
13
|
from configparser import RawConfigParser
|
13
14
|
from pathlib import Path
|
14
|
-
from typing import IO, Any,
|
15
|
+
from typing import IO, Any, Callable, Literal
|
15
16
|
|
16
17
|
import click
|
17
18
|
|
@@ -137,7 +138,7 @@ def resolve_reload_patterns(patterns_list: list[str], directories_list: list[str
|
|
137
138
|
# Special case for the .* pattern, otherwise this would only match
|
138
139
|
# hidden directories which is probably undesired
|
139
140
|
if pattern == ".*":
|
140
|
-
continue
|
141
|
+
continue # pragma: py-darwin
|
141
142
|
patterns.append(pattern)
|
142
143
|
if is_dir(Path(pattern)):
|
143
144
|
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/middleware/wsgi.py
CHANGED
@@ -3,7 +3,8 @@ from __future__ import annotations
|
|
3
3
|
import asyncio
|
4
4
|
import http
|
5
5
|
import logging
|
6
|
-
from
|
6
|
+
from collections.abc import Sequence
|
7
|
+
from typing import Any, Literal, Optional, cast
|
7
8
|
from urllib.parse import unquote
|
8
9
|
|
9
10
|
import websockets
|
@@ -224,6 +224,7 @@ class WSProtocol(asyncio.Protocol):
|
|
224
224
|
headers: list[tuple[bytes, bytes]] = [
|
225
225
|
(b"content-type", b"text/plain; charset=utf-8"),
|
226
226
|
(b"connection", b"close"),
|
227
|
+
(b"content-length", b"21"),
|
227
228
|
]
|
228
229
|
output = self.conn.send(wsproto.events.RejectConnection(status_code=500, headers=headers, has_body=True))
|
229
230
|
output += self.conn.send(wsproto.events.RejectData(data=b"Internal Server Error"))
|
uvicorn/server.py
CHANGED
@@ -10,9 +10,10 @@ import socket
|
|
10
10
|
import sys
|
11
11
|
import threading
|
12
12
|
import time
|
13
|
+
from collections.abc import Generator, Sequence
|
13
14
|
from email.utils import formatdate
|
14
15
|
from types import FrameType
|
15
|
-
from typing import TYPE_CHECKING,
|
16
|
+
from typing import TYPE_CHECKING, Union
|
16
17
|
|
17
18
|
import click
|
18
19
|
|
@@ -284,10 +285,7 @@ class Server:
|
|
284
285
|
len(self.server_state.tasks),
|
285
286
|
)
|
286
287
|
for t in self.server_state.tasks:
|
287
|
-
|
288
|
-
t.cancel()
|
289
|
-
else: # pragma: py-lt-39
|
290
|
-
t.cancel(msg="Task cancelled, timeout graceful shutdown exceeded")
|
288
|
+
t.cancel(msg="Task cancelled, timeout graceful shutdown exceeded")
|
291
289
|
|
292
290
|
# Send the lifespan shutdown event, and wait for application shutdown.
|
293
291
|
if not self.force_exit:
|
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"]
|
@@ -5,10 +5,11 @@ import os
|
|
5
5
|
import signal
|
6
6
|
import sys
|
7
7
|
import threading
|
8
|
+
from collections.abc import Iterator
|
8
9
|
from pathlib import Path
|
9
10
|
from socket import socket
|
10
11
|
from types import FrameType
|
11
|
-
from typing import Callable
|
12
|
+
from typing import Callable
|
12
13
|
|
13
14
|
import click
|
14
15
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import logging
|
4
|
+
from collections.abc import Iterator
|
4
5
|
from pathlib import Path
|
5
6
|
from socket import socket
|
6
|
-
from typing import Callable
|
7
|
+
from typing import Callable
|
7
8
|
|
8
9
|
from uvicorn.config import Config
|
9
10
|
from uvicorn.supervisors.basereload import BaseReload
|
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,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: uvicorn
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.34.0
|
4
4
|
Summary: The lightning-fast ASGI server.
|
5
5
|
Project-URL: Changelog, https://github.com/encode/uvicorn/blob/master/CHANGELOG.md
|
6
6
|
Project-URL: Funding, https://github.com/sponsors/encode
|
@@ -14,7 +14,6 @@ Classifier: Intended Audience :: Developers
|
|
14
14
|
Classifier: License :: OSI Approved :: BSD License
|
15
15
|
Classifier: Operating System :: OS Independent
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
17
|
-
Classifier: Programming Language :: Python :: 3.8
|
18
17
|
Classifier: Programming Language :: Python :: 3.9
|
19
18
|
Classifier: Programming Language :: Python :: 3.10
|
20
19
|
Classifier: Programming Language :: Python :: 3.11
|
@@ -23,7 +22,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
23
22
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
24
23
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
25
24
|
Classifier: Topic :: Internet :: WWW/HTTP
|
26
|
-
Requires-Python: >=3.
|
25
|
+
Requires-Python: >=3.9
|
27
26
|
Requires-Dist: click>=7.0
|
28
27
|
Requires-Dist: h11>=0.8
|
29
28
|
Requires-Dist: typing-extensions>=4.0; python_version < '3.11'
|
@@ -1,14 +1,14 @@
|
|
1
|
-
uvicorn/__init__.py,sha256=
|
1
|
+
uvicorn/__init__.py,sha256=6QKvxaTzHjM48izaeuZXBkVrqShBw6KeHswYwj4FwHg,147
|
2
2
|
uvicorn/__main__.py,sha256=DQizy6nKP0ywhPpnCHgmRDYIMfcqZKVEzNIWQZjqtVQ,62
|
3
3
|
uvicorn/_subprocess.py,sha256=HbfRnsCkXyg7xCWVAWWzXQTeWlvLKfTlIF5wevFBkR4,2766
|
4
|
-
uvicorn/_types.py,sha256=
|
5
|
-
uvicorn/config.py,sha256=
|
4
|
+
uvicorn/_types.py,sha256=5FcPvvIfeKsJDjGhTrceDv8TmwzYI8yPF7mXsXTWOUM,7775
|
5
|
+
uvicorn/config.py,sha256=bMSdgFZpD6wfQ0-ieIl3Ha3IVDFCGLtt0mpg-JVNtuY,20897
|
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
|
-
uvicorn/server.py,sha256=
|
11
|
-
uvicorn/workers.py,sha256=
|
10
|
+
uvicorn/server.py,sha256=jdPRUFI_0UCpmBxB8PrpY7hpsgwGTdlKt0IrxFN0jm8,12893
|
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
|
@@ -20,7 +20,7 @@ uvicorn/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
20
20
|
uvicorn/middleware/asgi2.py,sha256=YQrQNm3RehFts3mzk3k4yw8aD8Egtj0tRS3N45YkQa0,394
|
21
21
|
uvicorn/middleware/message_logger.py,sha256=IHEZUSnFNaMFUFdwtZO3AuFATnYcSor-gVtOjbCzt8M,2859
|
22
22
|
uvicorn/middleware/proxy_headers.py,sha256=f1VDAc-ipPHdNTuLNHwYCeDgYXoCL_VjD6hDTUXZT_U,5790
|
23
|
-
uvicorn/middleware/wsgi.py,sha256=
|
23
|
+
uvicorn/middleware/wsgi.py,sha256=F45FLfMZc510LiYpu7VQnoFpRof4k5pm5CTER4urs3U,7120
|
24
24
|
uvicorn/protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
25
|
uvicorn/protocols/utils.py,sha256=rCjYLd4_uwPeZkbRXQ6beCfxyI_oYpvJCwz3jEGNOiE,1849
|
26
26
|
uvicorn/protocols/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -30,16 +30,15 @@ uvicorn/protocols/http/h11_impl.py,sha256=4b-KswK57FBaRPeHXlK_oy8pKM6vG1haALCIeR
|
|
30
30
|
uvicorn/protocols/http/httptools_impl.py,sha256=tuQBCiD6rf5DQeyQwHVc45rxH9ouojMpkXi9KG6NRBk,21805
|
31
31
|
uvicorn/protocols/websockets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
32
|
uvicorn/protocols/websockets/auto.py,sha256=kNP-h07ZzjA9dKRUd7MNO0J7xhRJ5xVBfit7wCbdB0A,574
|
33
|
-
uvicorn/protocols/websockets/websockets_impl.py,sha256=
|
34
|
-
uvicorn/protocols/websockets/wsproto_impl.py,sha256=
|
35
|
-
uvicorn/supervisors/__init__.py,sha256=
|
36
|
-
uvicorn/supervisors/basereload.py,sha256=
|
33
|
+
uvicorn/protocols/websockets/websockets_impl.py,sha256=0y4kk-zR-uPdmpjq9OYuzJk7g9amlispUmM91lyqRdY,15517
|
34
|
+
uvicorn/protocols/websockets/wsproto_impl.py,sha256=ga8JzDUU2QrQsjgQdgIilfbmBHIrH4zbyGM4maovTRo,15381
|
35
|
+
uvicorn/supervisors/__init__.py,sha256=wT8eOEIqT1yWQgytZtv5taWMul7xoTIY0xm1m4oyPTw,507
|
36
|
+
uvicorn/supervisors/basereload.py,sha256=arOe3PqQp0L5FvCYDsVg8jUev-57syWFzHhggsM18VY,3858
|
37
37
|
uvicorn/supervisors/multiprocess.py,sha256=Opt0XvOUj1DIMXYwb4OlkJZxeh_RjweFnTmDPYItONw,7507
|
38
|
-
uvicorn/supervisors/statreload.py,sha256=
|
38
|
+
uvicorn/supervisors/statreload.py,sha256=hXznDIW3f54ltxik6hXsBSC-1qBFL30eCvtPSlIvn1o,1569
|
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.34.0.dist-info/METADATA,sha256=bS8aEm2BGuEU-2n8mLQYHWl5dD0TLAU3IxswLCB4QcU,6534
|
41
|
+
uvicorn-0.34.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
42
|
+
uvicorn-0.34.0.dist-info/entry_points.txt,sha256=FW1w-hkc9QgwaGoovMvm0ZY73w_NcycWdGAUfDsNGxw,46
|
43
|
+
uvicorn-0.34.0.dist-info/licenses/LICENSE.md,sha256=7-Gs8-YvuZwoiw7HPlp3O3Jo70Mg_nV-qZQhTktjw3E,1526
|
44
|
+
uvicorn-0.34.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
|