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 CHANGED
@@ -1,5 +1,5 @@
1
1
  from uvicorn.config import Config
2
2
  from uvicorn.main import Server, main, run
3
3
 
4
- __version__ = "0.34.1"
4
+ __version__ = "0.34.3"
5
5
  __all__ = ["main", "run", "Config", "Server"]
uvicorn/config.py CHANGED
@@ -313,7 +313,7 @@ class Config:
313
313
  + "directories, watching current working directory.",
314
314
  reload_dirs,
315
315
  )
316
- self.reload_dirs = [Path(os.getcwd())]
316
+ self.reload_dirs = [Path.cwd()]
317
317
 
318
318
  logger.info(
319
319
  "Will watch for changes in these directories: %s",
@@ -1,9 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import asyncio
4
- import typing
4
+ from typing import Callable
5
5
 
6
- AutoWebSocketsProtocol: typing.Callable[..., asyncio.Protocol] | None
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["client"],
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["client"],
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["client"],
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 typing
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, typing.Any],
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 = typing.cast(WebSocketAcceptEvent, message)
258
+ message = cast(WebSocketAcceptEvent, message)
259
259
  self.logger.info(
260
260
  '%s - "WebSocket %s" [accepted]',
261
- self.scope["client"],
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["client"],
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 = typing.cast(WebSocketResponseStartEvent, 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["client"],
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 = typing.cast(WebSocketSendEvent, 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 = typing.cast(WebSocketCloseEvent, 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 = typing.cast("WebSocketResponseBodyEvent", 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
- if Path.cwd() not in directory.parents:
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.1
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!=0.15.0,!=0.15.1,>=0.14.0; (sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy')) and extra == 'standard'
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=SXztotDlDwRpwhxNAxosheuUoUmf8R6AKtYW5NiOToE,147
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=zg-UX2vu3Zy0e7jXOJKoY1mPhsbIuq-3IwwKy9yERkg,20894
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=kNP-h07ZzjA9dKRUd7MNO0J7xhRJ5xVBfit7wCbdB0A,574
33
- uvicorn/protocols/websockets/websockets_impl.py,sha256=E0e7aX4ICmSIuytfc4d5RhWvjH37Ed8ZgXwAH2f8oog,15504
34
- uvicorn/protocols/websockets/wsproto_impl.py,sha256=2OB4E6OsQ1KPiETkHYi2UQDxY9sUzTr0LLZQJxlXPxo,15375
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=arOe3PqQp0L5FvCYDsVg8jUev-57syWFzHhggsM18VY,3858
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=41FGNMXPKrKvPr-5O8yRWg43l6OCBtapt39M-gpdk0E,3010
40
- uvicorn-0.34.1.dist-info/METADATA,sha256=O2eY1scXzGrYzwSaRblLDbHpkBnzhrLXZ1AFsm6xmlw,6549
41
- uvicorn-0.34.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
42
- uvicorn-0.34.1.dist-info/entry_points.txt,sha256=FW1w-hkc9QgwaGoovMvm0ZY73w_NcycWdGAUfDsNGxw,46
43
- uvicorn-0.34.1.dist-info/licenses/LICENSE.md,sha256=7-Gs8-YvuZwoiw7HPlp3O3Jo70Mg_nV-qZQhTktjw3E,1526
44
- uvicorn-0.34.1.dist-info/RECORD,,
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,,