uvicorn 0.34.1__py3-none-any.whl → 0.34.3__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/protocols/websockets/auto.py +2 -2
- uvicorn/protocols/websockets/websockets_impl.py +4 -3
- uvicorn/protocols/websockets/wsproto_impl.py +11 -11
- uvicorn/supervisors/basereload.py +4 -0
- uvicorn/supervisors/watchfilesreload.py +1 -4
- {uvicorn-0.34.1.dist-info → uvicorn-0.34.3.dist-info}/METADATA +2 -2
- {uvicorn-0.34.1.dist-info → uvicorn-0.34.3.dist-info}/RECORD +12 -12
- {uvicorn-0.34.1.dist-info → uvicorn-0.34.3.dist-info}/WHEEL +0 -0
- {uvicorn-0.34.1.dist-info → uvicorn-0.34.3.dist-info}/entry_points.txt +0 -0
- {uvicorn-0.34.1.dist-info → uvicorn-0.34.3.dist-info}/licenses/LICENSE.md +0 -0
uvicorn/__init__.py
CHANGED
uvicorn/config.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import asyncio
|
4
|
-
import
|
4
|
+
from typing import Callable
|
5
5
|
|
6
|
-
AutoWebSocketsProtocol:
|
6
|
+
AutoWebSocketsProtocol: Callable[..., asyncio.Protocol] | None
|
7
7
|
try:
|
8
8
|
import websockets # noqa
|
9
9
|
except ImportError: # pragma: no cover
|
@@ -34,6 +34,7 @@ from uvicorn.config import Config
|
|
34
34
|
from uvicorn.logging import TRACE_LOG_LEVEL
|
35
35
|
from uvicorn.protocols.utils import (
|
36
36
|
ClientDisconnected,
|
37
|
+
get_client_addr,
|
37
38
|
get_local_addr,
|
38
39
|
get_path_with_query_string,
|
39
40
|
get_remote_addr,
|
@@ -271,7 +272,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
|
271
272
|
message = cast("WebSocketAcceptEvent", message)
|
272
273
|
self.logger.info(
|
273
274
|
'%s - "WebSocket %s" [accepted]',
|
274
|
-
self.scope
|
275
|
+
get_client_addr(self.scope),
|
275
276
|
get_path_with_query_string(self.scope),
|
276
277
|
)
|
277
278
|
self.initial_response = None
|
@@ -289,7 +290,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
|
289
290
|
message = cast("WebSocketCloseEvent", message)
|
290
291
|
self.logger.info(
|
291
292
|
'%s - "WebSocket %s" 403',
|
292
|
-
self.scope
|
293
|
+
get_client_addr(self.scope),
|
293
294
|
get_path_with_query_string(self.scope),
|
294
295
|
)
|
295
296
|
self.initial_response = (http.HTTPStatus.FORBIDDEN, [], b"")
|
@@ -300,7 +301,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
|
300
301
|
message = cast("WebSocketResponseStartEvent", message)
|
301
302
|
self.logger.info(
|
302
303
|
'%s - "WebSocket %s" %d',
|
303
|
-
self.scope
|
304
|
+
get_client_addr(self.scope),
|
304
305
|
get_path_with_query_string(self.scope),
|
305
306
|
message["status"],
|
306
307
|
)
|
@@ -2,8 +2,7 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import asyncio
|
4
4
|
import logging
|
5
|
-
import
|
6
|
-
from typing import Literal, cast
|
5
|
+
from typing import Any, Literal, cast
|
7
6
|
from urllib.parse import unquote
|
8
7
|
|
9
8
|
import wsproto
|
@@ -27,6 +26,7 @@ from uvicorn.config import Config
|
|
27
26
|
from uvicorn.logging import TRACE_LOG_LEVEL
|
28
27
|
from uvicorn.protocols.utils import (
|
29
28
|
ClientDisconnected,
|
29
|
+
get_client_addr,
|
30
30
|
get_local_addr,
|
31
31
|
get_path_with_query_string,
|
32
32
|
get_remote_addr,
|
@@ -40,7 +40,7 @@ class WSProtocol(asyncio.Protocol):
|
|
40
40
|
self,
|
41
41
|
config: Config,
|
42
42
|
server_state: ServerState,
|
43
|
-
app_state: dict[str,
|
43
|
+
app_state: dict[str, Any],
|
44
44
|
_loop: asyncio.AbstractEventLoop | None = None,
|
45
45
|
) -> None:
|
46
46
|
if not config.loaded:
|
@@ -255,10 +255,10 @@ class WSProtocol(asyncio.Protocol):
|
|
255
255
|
|
256
256
|
if not self.handshake_complete:
|
257
257
|
if message_type == "websocket.accept":
|
258
|
-
message =
|
258
|
+
message = cast(WebSocketAcceptEvent, message)
|
259
259
|
self.logger.info(
|
260
260
|
'%s - "WebSocket %s" [accepted]',
|
261
|
-
self.scope
|
261
|
+
get_client_addr(self.scope),
|
262
262
|
get_path_with_query_string(self.scope),
|
263
263
|
)
|
264
264
|
subprotocol = message.get("subprotocol")
|
@@ -281,7 +281,7 @@ class WSProtocol(asyncio.Protocol):
|
|
281
281
|
self.queue.put_nowait({"type": "websocket.disconnect", "code": 1006})
|
282
282
|
self.logger.info(
|
283
283
|
'%s - "WebSocket %s" 403',
|
284
|
-
self.scope
|
284
|
+
get_client_addr(self.scope),
|
285
285
|
get_path_with_query_string(self.scope),
|
286
286
|
)
|
287
287
|
self.handshake_complete = True
|
@@ -292,14 +292,14 @@ class WSProtocol(asyncio.Protocol):
|
|
292
292
|
self.transport.close()
|
293
293
|
|
294
294
|
elif message_type == "websocket.http.response.start":
|
295
|
-
message =
|
295
|
+
message = cast(WebSocketResponseStartEvent, message)
|
296
296
|
# ensure status code is in the valid range
|
297
297
|
if not (100 <= message["status"] < 600):
|
298
298
|
msg = "Invalid HTTP status code '%d' in response."
|
299
299
|
raise RuntimeError(msg % message["status"])
|
300
300
|
self.logger.info(
|
301
301
|
'%s - "WebSocket %s" %d',
|
302
|
-
self.scope
|
302
|
+
get_client_addr(self.scope),
|
303
303
|
get_path_with_query_string(self.scope),
|
304
304
|
message["status"],
|
305
305
|
)
|
@@ -324,7 +324,7 @@ class WSProtocol(asyncio.Protocol):
|
|
324
324
|
elif not self.close_sent and not self.response_started:
|
325
325
|
try:
|
326
326
|
if message_type == "websocket.send":
|
327
|
-
message =
|
327
|
+
message = cast(WebSocketSendEvent, message)
|
328
328
|
bytes_data = message.get("bytes")
|
329
329
|
text_data = message.get("text")
|
330
330
|
data = text_data if bytes_data is None else bytes_data
|
@@ -333,7 +333,7 @@ class WSProtocol(asyncio.Protocol):
|
|
333
333
|
self.transport.write(output)
|
334
334
|
|
335
335
|
elif message_type == "websocket.close":
|
336
|
-
message =
|
336
|
+
message = cast(WebSocketCloseEvent, message)
|
337
337
|
self.close_sent = True
|
338
338
|
code = message.get("code", 1000)
|
339
339
|
reason = message.get("reason", "") or ""
|
@@ -350,7 +350,7 @@ class WSProtocol(asyncio.Protocol):
|
|
350
350
|
raise ClientDisconnected from exc
|
351
351
|
elif self.response_started:
|
352
352
|
if message_type == "websocket.http.response.body":
|
353
|
-
message =
|
353
|
+
message = cast("WebSocketResponseBodyEvent", message)
|
354
354
|
body_finished = not message.get("more_body", False)
|
355
355
|
reject_data = events.RejectData(data=message["body"], body_finished=body_finished)
|
356
356
|
output = self.conn.send(reject_data)
|
@@ -90,6 +90,10 @@ class BaseReload:
|
|
90
90
|
self.is_restarting = True
|
91
91
|
assert self.process.pid is not None
|
92
92
|
os.kill(self.process.pid, signal.CTRL_C_EVENT)
|
93
|
+
|
94
|
+
# This is a workaround to ensure the Ctrl+C event is processed
|
95
|
+
sys.stdout.write(" ") # This has to be a non-empty string
|
96
|
+
sys.stdout.flush()
|
93
97
|
else: # pragma: py-win32
|
94
98
|
self.process.terminate()
|
95
99
|
self.process.join()
|
@@ -63,10 +63,7 @@ class WatchFilesReload(BaseReload):
|
|
63
63
|
self.reloader_name = "WatchFiles"
|
64
64
|
self.reload_dirs = []
|
65
65
|
for directory in config.reload_dirs:
|
66
|
-
|
67
|
-
self.reload_dirs.append(directory)
|
68
|
-
if Path.cwd() not in self.reload_dirs:
|
69
|
-
self.reload_dirs.append(Path.cwd())
|
66
|
+
self.reload_dirs.append(directory)
|
70
67
|
|
71
68
|
self.watch_filter = FileFilter(config)
|
72
69
|
self.watcher = watch(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: uvicorn
|
3
|
-
Version: 0.34.
|
3
|
+
Version: 0.34.3
|
4
4
|
Summary: The lightning-fast ASGI server.
|
5
5
|
Project-URL: Changelog, https://www.uvicorn.org/release-notes
|
6
6
|
Project-URL: Funding, https://github.com/sponsors/encode
|
@@ -32,7 +32,7 @@ Requires-Dist: colorama>=0.4; (sys_platform == 'win32') and extra == 'standard'
|
|
32
32
|
Requires-Dist: httptools>=0.6.3; extra == 'standard'
|
33
33
|
Requires-Dist: python-dotenv>=0.13; extra == 'standard'
|
34
34
|
Requires-Dist: pyyaml>=5.1; extra == 'standard'
|
35
|
-
Requires-Dist: uvloop
|
35
|
+
Requires-Dist: uvloop>=0.15.1; (sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy')) and extra == 'standard'
|
36
36
|
Requires-Dist: watchfiles>=0.13; extra == 'standard'
|
37
37
|
Requires-Dist: websockets>=10.4; extra == 'standard'
|
38
38
|
Description-Content-Type: text/markdown
|
@@ -1,8 +1,8 @@
|
|
1
|
-
uvicorn/__init__.py,sha256=
|
1
|
+
uvicorn/__init__.py,sha256=4LwEp7joIjTJGVCgzB4GQTAoFBH4AYD2O-EPCYxWt6M,147
|
2
2
|
uvicorn/__main__.py,sha256=DQizy6nKP0ywhPpnCHgmRDYIMfcqZKVEzNIWQZjqtVQ,62
|
3
3
|
uvicorn/_subprocess.py,sha256=HbfRnsCkXyg7xCWVAWWzXQTeWlvLKfTlIF5wevFBkR4,2766
|
4
4
|
uvicorn/_types.py,sha256=5FcPvvIfeKsJDjGhTrceDv8TmwzYI8yPF7mXsXTWOUM,7775
|
5
|
-
uvicorn/config.py,sha256=
|
5
|
+
uvicorn/config.py,sha256=J6tdBhwecNgUJHX0CbIYHJ828Sl3WKyercf6QhSzGmM,20887
|
6
6
|
uvicorn/importer.py,sha256=nRt0QQ3qpi264-n_mR0l55C2ddM8nowTNzT1jsWaam8,1128
|
7
7
|
uvicorn/logging.py,sha256=-eCE4nOJmFbtB9qfNJuEVNF0Y13LGUHqvFzemYT0PaQ,4235
|
8
8
|
uvicorn/main.py,sha256=5TFzub2UbSk4LOQ_UeQ3PZLiTRG51KIQ0sSY9SZUMN8,17234
|
@@ -29,16 +29,16 @@ uvicorn/protocols/http/flow_control.py,sha256=050WVg31EvPOkHwynCoMP1zXFl_vO3U4du
|
|
29
29
|
uvicorn/protocols/http/h11_impl.py,sha256=4b-KswK57FBaRPeHXlK_oy8pKM6vG1haALCIeRH-1bA,20694
|
30
30
|
uvicorn/protocols/http/httptools_impl.py,sha256=tuQBCiD6rf5DQeyQwHVc45rxH9ouojMpkXi9KG6NRBk,21805
|
31
31
|
uvicorn/protocols/websockets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
|
-
uvicorn/protocols/websockets/auto.py,sha256=
|
33
|
-
uvicorn/protocols/websockets/websockets_impl.py,sha256=
|
34
|
-
uvicorn/protocols/websockets/wsproto_impl.py,sha256=
|
32
|
+
uvicorn/protocols/websockets/auto.py,sha256=SH_KV_3vwR8_oGda2GrHFt38VG-IwY0ufjvHOu4VA0o,581
|
33
|
+
uvicorn/protocols/websockets/websockets_impl.py,sha256=qonQJxz9wMKMwB2RnYZezeP-XfmAsxCvNeGgu4sC3Lc,15546
|
34
|
+
uvicorn/protocols/websockets/wsproto_impl.py,sha256=u2TKyzRUCmQpS1e4E_X6Uou9QIuoKZNNNmHU1IzkWPU,15366
|
35
35
|
uvicorn/supervisors/__init__.py,sha256=wT8eOEIqT1yWQgytZtv5taWMul7xoTIY0xm1m4oyPTw,507
|
36
|
-
uvicorn/supervisors/basereload.py,sha256=
|
36
|
+
uvicorn/supervisors/basereload.py,sha256=MAXSQ3ckZPwqzJ8Un9yDhk3W0yyAArQtZLuOE0OInSc,4036
|
37
37
|
uvicorn/supervisors/multiprocess.py,sha256=Opt0XvOUj1DIMXYwb4OlkJZxeh_RjweFnTmDPYItONw,7507
|
38
38
|
uvicorn/supervisors/statreload.py,sha256=uYblmoxM3IbPbvMDzr5Abw2-WykQl8NxTTzeLfVyvnU,1566
|
39
|
-
uvicorn/supervisors/watchfilesreload.py,sha256=
|
40
|
-
uvicorn-0.34.
|
41
|
-
uvicorn-0.34.
|
42
|
-
uvicorn-0.34.
|
43
|
-
uvicorn-0.34.
|
44
|
-
uvicorn-0.34.
|
39
|
+
uvicorn/supervisors/watchfilesreload.py,sha256=W86Ybb0E5SdMYYuWHJ3bpAFXdw5ZurvLRdFcvLnYEIA,2859
|
40
|
+
uvicorn-0.34.3.dist-info/METADATA,sha256=RC1OrruxWAfCxWLXP-xUUok8GH9Pez4iIYFFum5dBnA,6531
|
41
|
+
uvicorn-0.34.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
42
|
+
uvicorn-0.34.3.dist-info/entry_points.txt,sha256=FW1w-hkc9QgwaGoovMvm0ZY73w_NcycWdGAUfDsNGxw,46
|
43
|
+
uvicorn-0.34.3.dist-info/licenses/LICENSE.md,sha256=7-Gs8-YvuZwoiw7HPlp3O3Jo70Mg_nV-qZQhTktjw3E,1526
|
44
|
+
uvicorn-0.34.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|