ominfra 0.0.0.dev219__py3-none-any.whl → 0.0.0.dev220__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.
- ominfra/scripts/supervisor.py +66 -38
- {ominfra-0.0.0.dev219.dist-info → ominfra-0.0.0.dev220.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev219.dist-info → ominfra-0.0.0.dev220.dist-info}/RECORD +7 -7
- {ominfra-0.0.0.dev219.dist-info → ominfra-0.0.0.dev220.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev219.dist-info → ominfra-0.0.0.dev220.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev219.dist-info → ominfra-0.0.0.dev220.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev219.dist-info → ominfra-0.0.0.dev220.dist-info}/top_level.txt +0 -0
ominfra/scripts/supervisor.py
CHANGED
@@ -6850,12 +6850,20 @@ class HttpHandlerResponse:
|
|
6850
6850
|
data: ta.Optional[HttpHandlerResponseData] = None
|
6851
6851
|
close_connection: ta.Optional[bool] = None
|
6852
6852
|
|
6853
|
+
def close(self) -> None:
|
6854
|
+
if isinstance(d := self.data, HttpHandlerResponseStreamedData):
|
6855
|
+
d.close()
|
6856
|
+
|
6853
6857
|
|
6854
6858
|
@dc.dataclass(frozen=True)
|
6855
6859
|
class HttpHandlerResponseStreamedData:
|
6856
6860
|
iter: ta.Iterable[bytes]
|
6857
6861
|
length: ta.Optional[int] = None
|
6858
6862
|
|
6863
|
+
def close(self) -> None:
|
6864
|
+
if hasattr(d := self.iter, 'close'):
|
6865
|
+
d.close() # noqa
|
6866
|
+
|
6859
6867
|
|
6860
6868
|
class HttpHandlerError(Exception):
|
6861
6869
|
pass
|
@@ -7383,6 +7391,10 @@ class CoroHttpServer:
|
|
7383
7391
|
return h
|
7384
7392
|
return None
|
7385
7393
|
|
7394
|
+
def close(self) -> None:
|
7395
|
+
if isinstance(d := self.data, HttpHandlerResponseStreamedData):
|
7396
|
+
d.close()
|
7397
|
+
|
7386
7398
|
#
|
7387
7399
|
|
7388
7400
|
def _build_response_head_bytes(self, a: _Response) -> bytes:
|
@@ -7598,35 +7610,45 @@ class CoroHttpServer:
|
|
7598
7610
|
while True:
|
7599
7611
|
gen = self.coro_handle_one()
|
7600
7612
|
|
7601
|
-
o = next(gen)
|
7602
7613
|
i: ta.Optional[bytes]
|
7614
|
+
o: ta.Any = next(gen)
|
7603
7615
|
while True:
|
7604
|
-
|
7605
|
-
|
7606
|
-
|
7616
|
+
try:
|
7617
|
+
if isinstance(o, self.AnyLogIo):
|
7618
|
+
i = None
|
7619
|
+
yield o
|
7607
7620
|
|
7608
|
-
|
7609
|
-
|
7621
|
+
elif isinstance(o, self.AnyReadIo):
|
7622
|
+
i = check.isinstance((yield o), bytes)
|
7610
7623
|
|
7611
|
-
|
7612
|
-
|
7624
|
+
elif isinstance(o, self._Response):
|
7625
|
+
i = None
|
7613
7626
|
|
7614
|
-
|
7615
|
-
|
7616
|
-
|
7627
|
+
r = self._preprocess_response(o)
|
7628
|
+
hb = self._build_response_head_bytes(r)
|
7629
|
+
check.none((yield self.WriteIo(hb)))
|
7617
7630
|
|
7618
|
-
|
7619
|
-
|
7631
|
+
for b in self._yield_response_data(r):
|
7632
|
+
yield self.WriteIo(b)
|
7620
7633
|
|
7621
|
-
|
7622
|
-
|
7634
|
+
o.close()
|
7635
|
+
o = None
|
7623
7636
|
|
7624
|
-
|
7625
|
-
|
7626
|
-
|
7627
|
-
|
7628
|
-
|
7629
|
-
|
7637
|
+
else:
|
7638
|
+
raise TypeError(o) # noqa
|
7639
|
+
|
7640
|
+
try:
|
7641
|
+
o = gen.send(i)
|
7642
|
+
except EOFError:
|
7643
|
+
return
|
7644
|
+
except StopIteration:
|
7645
|
+
break
|
7646
|
+
|
7647
|
+
except Exception: # noqa
|
7648
|
+
if hasattr(o, 'close'):
|
7649
|
+
o.close()
|
7650
|
+
|
7651
|
+
raise
|
7630
7652
|
|
7631
7653
|
def coro_handle_one(self) -> ta.Generator[
|
7632
7654
|
ta.Union[AnyLogIo, AnyReadIo, _Response],
|
@@ -7708,28 +7730,34 @@ class CoroHttpServer:
|
|
7708
7730
|
yield self._build_error_response(err)
|
7709
7731
|
return
|
7710
7732
|
|
7711
|
-
|
7733
|
+
try:
|
7734
|
+
# Build internal response
|
7712
7735
|
|
7713
|
-
|
7714
|
-
|
7736
|
+
response_headers = handler_response.headers or {}
|
7737
|
+
response_data = handler_response.data
|
7715
7738
|
|
7716
|
-
|
7717
|
-
|
7718
|
-
|
7739
|
+
headers: ta.List[CoroHttpServer._Header] = [
|
7740
|
+
*self._make_default_headers(),
|
7741
|
+
]
|
7719
7742
|
|
7720
|
-
|
7721
|
-
|
7743
|
+
for k, v in response_headers.items():
|
7744
|
+
headers.append(self._Header(k, v))
|
7722
7745
|
|
7723
|
-
|
7724
|
-
|
7746
|
+
if handler_response.close_connection and 'Connection' not in headers:
|
7747
|
+
headers.append(self._Header('Connection', 'close'))
|
7725
7748
|
|
7726
|
-
|
7727
|
-
|
7728
|
-
|
7729
|
-
|
7730
|
-
|
7731
|
-
|
7732
|
-
|
7749
|
+
yield self._Response(
|
7750
|
+
version=parsed.version,
|
7751
|
+
code=http.HTTPStatus(handler_response.status),
|
7752
|
+
headers=headers,
|
7753
|
+
data=response_data,
|
7754
|
+
close_connection=handler_response.close_connection,
|
7755
|
+
)
|
7756
|
+
|
7757
|
+
except Exception: # noqa
|
7758
|
+
handler_response.close()
|
7759
|
+
|
7760
|
+
raise
|
7733
7761
|
|
7734
7762
|
|
7735
7763
|
##
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ominfra
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev220
|
4
4
|
Summary: ominfra
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Operating System :: POSIX
|
13
13
|
Requires-Python: >=3.12
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: omdev==0.0.0.
|
16
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omdev==0.0.0.dev220
|
16
|
+
Requires-Dist: omlish==0.0.0.dev220
|
17
17
|
Provides-Extra: all
|
18
18
|
Requires-Dist: paramiko~=3.5; extra == "all"
|
19
19
|
Requires-Dist: asyncssh~=2.18; extra == "all"
|
@@ -114,7 +114,7 @@ ominfra/manage/targets/targets.py,sha256=7GP6UAZyJFEhpkJN6UQdpr_WN3p7C76v-s445y-
|
|
114
114
|
ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
115
115
|
ominfra/scripts/journald2aws.py,sha256=CM1nZMpecXJpcg7icJUCJ-_DX-7CduQurxZQ7EmhQmA,171450
|
116
116
|
ominfra/scripts/manage.py,sha256=MaUur1_dDdMHt5YnE6Waxa_v70kydHzKCBHXAuTmKd0,362827
|
117
|
-
ominfra/scripts/supervisor.py,sha256=
|
117
|
+
ominfra/scripts/supervisor.py,sha256=7rHuykKUftnClZnwIE3V75k7ESEt4u1Y6l5qo_ifI6E,296250
|
118
118
|
ominfra/supervisor/LICENSE.txt,sha256=ZrHY15PVR98y26Yg6iQfa-SXnUaYTDhrUsPVcEO5OKM,1874
|
119
119
|
ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
120
120
|
ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
|
@@ -156,9 +156,9 @@ ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
|
|
156
156
|
ominfra/tailscale/cli.py,sha256=3FnJbgpLw6gInTfhERd1mDy9ijjMUGxkdYVo43Tnxx4,3555
|
157
157
|
ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
158
158
|
ominfra/tools/listresources.py,sha256=BxFoxtyF2aVEcW67ZD9QujoBkJBtvIxGmKqXvLwnEHo,6180
|
159
|
-
ominfra-0.0.0.
|
160
|
-
ominfra-0.0.0.
|
161
|
-
ominfra-0.0.0.
|
162
|
-
ominfra-0.0.0.
|
163
|
-
ominfra-0.0.0.
|
164
|
-
ominfra-0.0.0.
|
159
|
+
ominfra-0.0.0.dev220.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
160
|
+
ominfra-0.0.0.dev220.dist-info/METADATA,sha256=ZGFJV5Q1uT6rEdQR9oMzSmL3uuJARCDlM2QeJJ0n_vI,731
|
161
|
+
ominfra-0.0.0.dev220.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
162
|
+
ominfra-0.0.0.dev220.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
|
163
|
+
ominfra-0.0.0.dev220.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
|
164
|
+
ominfra-0.0.0.dev220.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|