ominfra 0.0.0.dev144__py3-none-any.whl → 0.0.0.dev145__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/manage/commands/execution.py +1 -1
- ominfra/manage/commands/inject.py +2 -3
- ominfra/manage/deploy/paths.py +33 -0
- ominfra/manage/main.py +2 -1
- ominfra/manage/remote/execution.py +2 -1
- ominfra/scripts/journald2aws.py +73 -53
- ominfra/scripts/manage.py +77 -58
- ominfra/scripts/supervisor.py +114 -94
- ominfra/supervisor/dispatchers.py +3 -3
- ominfra/supervisor/http.py +6 -6
- ominfra/supervisor/inject.py +12 -12
- ominfra/supervisor/io.py +2 -2
- ominfra/supervisor/spawningimpl.py +2 -2
- ominfra/supervisor/supervisor.py +2 -2
- ominfra/supervisor/types.py +2 -2
- {ominfra-0.0.0.dev144.dist-info → ominfra-0.0.0.dev145.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev144.dist-info → ominfra-0.0.0.dev145.dist-info}/RECORD +21 -20
- {ominfra-0.0.0.dev144.dist-info → ominfra-0.0.0.dev145.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev144.dist-info → ominfra-0.0.0.dev145.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev144.dist-info → ominfra-0.0.0.dev145.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev144.dist-info → ominfra-0.0.0.dev145.dist-info}/top_level.txt +0 -0
ominfra/scripts/supervisor.py
CHANGED
@@ -1565,7 +1565,7 @@ def check_non_empty(v: SizedT) -> SizedT:
|
|
1565
1565
|
##
|
1566
1566
|
|
1567
1567
|
|
1568
|
-
class
|
1568
|
+
class FdioPoller(abc.ABC):
|
1569
1569
|
def __init__(self) -> None:
|
1570
1570
|
super().__init__()
|
1571
1571
|
|
@@ -1676,8 +1676,8 @@ class FdIoPoller(abc.ABC):
|
|
1676
1676
|
##
|
1677
1677
|
|
1678
1678
|
|
1679
|
-
class
|
1680
|
-
def poll(self, timeout: ta.Optional[float]) ->
|
1679
|
+
class SelectFdioPoller(FdioPoller):
|
1680
|
+
def poll(self, timeout: ta.Optional[float]) -> FdioPoller.PollResult:
|
1681
1681
|
try:
|
1682
1682
|
r, w, x = select.select(
|
1683
1683
|
self._readable,
|
@@ -1688,22 +1688,22 @@ class SelectFdIoPoller(FdIoPoller):
|
|
1688
1688
|
|
1689
1689
|
except OSError as exc:
|
1690
1690
|
if exc.errno == errno.EINTR:
|
1691
|
-
return
|
1691
|
+
return FdioPoller.PollResult(msg='EINTR encountered in poll', exc=exc)
|
1692
1692
|
elif exc.errno == errno.EBADF:
|
1693
|
-
return
|
1693
|
+
return FdioPoller.PollResult(msg='EBADF encountered in poll', exc=exc)
|
1694
1694
|
else:
|
1695
1695
|
raise
|
1696
1696
|
|
1697
|
-
return
|
1697
|
+
return FdioPoller.PollResult(r, w)
|
1698
1698
|
|
1699
1699
|
|
1700
1700
|
##
|
1701
1701
|
|
1702
1702
|
|
1703
|
-
|
1703
|
+
PollFdioPoller: ta.Optional[ta.Type[FdioPoller]]
|
1704
1704
|
if hasattr(select, 'poll'):
|
1705
1705
|
|
1706
|
-
class
|
1706
|
+
class _PollFdioPoller(FdioPoller):
|
1707
1707
|
def __init__(self) -> None:
|
1708
1708
|
super().__init__()
|
1709
1709
|
|
@@ -1736,14 +1736,14 @@ if hasattr(select, 'poll'):
|
|
1736
1736
|
|
1737
1737
|
#
|
1738
1738
|
|
1739
|
-
def poll(self, timeout: ta.Optional[float]) ->
|
1739
|
+
def poll(self, timeout: ta.Optional[float]) -> FdioPoller.PollResult:
|
1740
1740
|
polled: ta.List[ta.Tuple[int, int]]
|
1741
1741
|
try:
|
1742
1742
|
polled = self._poller.poll(timeout * 1000 if timeout is not None else None)
|
1743
1743
|
|
1744
1744
|
except OSError as exc:
|
1745
1745
|
if exc.errno == errno.EINTR:
|
1746
|
-
return
|
1746
|
+
return FdioPoller.PollResult(msg='EINTR encountered in poll', exc=exc)
|
1747
1747
|
else:
|
1748
1748
|
raise
|
1749
1749
|
|
@@ -1761,11 +1761,11 @@ if hasattr(select, 'poll'):
|
|
1761
1761
|
r.append(fd)
|
1762
1762
|
if mask & self._WRITE:
|
1763
1763
|
w.append(fd)
|
1764
|
-
return
|
1764
|
+
return FdioPoller.PollResult(r, w, inv=inv)
|
1765
1765
|
|
1766
|
-
|
1766
|
+
PollFdioPoller = _PollFdioPoller
|
1767
1767
|
else:
|
1768
|
-
|
1768
|
+
PollFdioPoller = None
|
1769
1769
|
|
1770
1770
|
|
1771
1771
|
########################################
|
@@ -2600,7 +2600,7 @@ def attr_setting(obj, attr, val, *, default=None): # noqa
|
|
2600
2600
|
# ../../../omlish/lite/fdio/handlers.py
|
2601
2601
|
|
2602
2602
|
|
2603
|
-
class
|
2603
|
+
class FdioHandler(abc.ABC):
|
2604
2604
|
@abc.abstractmethod
|
2605
2605
|
def fd(self) -> int:
|
2606
2606
|
raise NotImplementedError
|
@@ -2636,7 +2636,7 @@ class FdIoHandler(abc.ABC):
|
|
2636
2636
|
pass
|
2637
2637
|
|
2638
2638
|
|
2639
|
-
class
|
2639
|
+
class SocketFdioHandler(FdioHandler, abc.ABC):
|
2640
2640
|
def __init__(
|
2641
2641
|
self,
|
2642
2642
|
addr: SocketAddress,
|
@@ -2664,10 +2664,10 @@ class SocketFdIoHandler(FdIoHandler, abc.ABC):
|
|
2664
2664
|
# ../../../omlish/lite/fdio/kqueue.py
|
2665
2665
|
|
2666
2666
|
|
2667
|
-
|
2667
|
+
KqueueFdioPoller: ta.Optional[ta.Type[FdioPoller]]
|
2668
2668
|
if sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
|
2669
2669
|
|
2670
|
-
class
|
2670
|
+
class _KqueueFdioPoller(FdioPoller):
|
2671
2671
|
DEFAULT_MAX_EVENTS = 1000
|
2672
2672
|
|
2673
2673
|
def __init__(
|
@@ -2755,14 +2755,14 @@ if sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
|
|
2755
2755
|
|
2756
2756
|
#
|
2757
2757
|
|
2758
|
-
def poll(self, timeout: ta.Optional[float]) ->
|
2758
|
+
def poll(self, timeout: ta.Optional[float]) -> FdioPoller.PollResult:
|
2759
2759
|
kq = self._get_kqueue()
|
2760
2760
|
try:
|
2761
2761
|
kes = kq.control(None, self._max_events, timeout)
|
2762
2762
|
|
2763
2763
|
except OSError as exc:
|
2764
2764
|
if exc.errno == errno.EINTR:
|
2765
|
-
return
|
2765
|
+
return FdioPoller.PollResult(msg='EINTR encountered in poll', exc=exc)
|
2766
2766
|
else:
|
2767
2767
|
raise
|
2768
2768
|
|
@@ -2774,11 +2774,11 @@ if sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
|
|
2774
2774
|
if ke.filter == select.KQ_FILTER_WRITE:
|
2775
2775
|
w.append(ke.ident)
|
2776
2776
|
|
2777
|
-
return
|
2777
|
+
return FdioPoller.PollResult(r, w)
|
2778
2778
|
|
2779
|
-
|
2779
|
+
KqueueFdioPoller = _KqueueFdioPoller
|
2780
2780
|
else:
|
2781
|
-
|
2781
|
+
KqueueFdioPoller = None
|
2782
2782
|
|
2783
2783
|
|
2784
2784
|
########################################
|
@@ -4738,23 +4738,24 @@ TODO:
|
|
4738
4738
|
@dc.dataclass(frozen=True)
|
4739
4739
|
class ObjMarshalOptions:
|
4740
4740
|
raw_bytes: bool = False
|
4741
|
+
nonstrict_dataclasses: bool = False
|
4741
4742
|
|
4742
4743
|
|
4743
4744
|
class ObjMarshaler(abc.ABC):
|
4744
4745
|
@abc.abstractmethod
|
4745
|
-
def marshal(self, o: ta.Any,
|
4746
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4746
4747
|
raise NotImplementedError
|
4747
4748
|
|
4748
4749
|
@abc.abstractmethod
|
4749
|
-
def unmarshal(self, o: ta.Any,
|
4750
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4750
4751
|
raise NotImplementedError
|
4751
4752
|
|
4752
4753
|
|
4753
4754
|
class NopObjMarshaler(ObjMarshaler):
|
4754
|
-
def marshal(self, o: ta.Any,
|
4755
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4755
4756
|
return o
|
4756
4757
|
|
4757
|
-
def unmarshal(self, o: ta.Any,
|
4758
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4758
4759
|
return o
|
4759
4760
|
|
4760
4761
|
|
@@ -4762,29 +4763,29 @@ class NopObjMarshaler(ObjMarshaler):
|
|
4762
4763
|
class ProxyObjMarshaler(ObjMarshaler):
|
4763
4764
|
m: ta.Optional[ObjMarshaler] = None
|
4764
4765
|
|
4765
|
-
def marshal(self, o: ta.Any,
|
4766
|
-
return check_not_none(self.m).marshal(o,
|
4766
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4767
|
+
return check_not_none(self.m).marshal(o, ctx)
|
4767
4768
|
|
4768
|
-
def unmarshal(self, o: ta.Any,
|
4769
|
-
return check_not_none(self.m).unmarshal(o,
|
4769
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4770
|
+
return check_not_none(self.m).unmarshal(o, ctx)
|
4770
4771
|
|
4771
4772
|
|
4772
4773
|
@dc.dataclass(frozen=True)
|
4773
4774
|
class CastObjMarshaler(ObjMarshaler):
|
4774
4775
|
ty: type
|
4775
4776
|
|
4776
|
-
def marshal(self, o: ta.Any,
|
4777
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4777
4778
|
return o
|
4778
4779
|
|
4779
|
-
def unmarshal(self, o: ta.Any,
|
4780
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4780
4781
|
return self.ty(o)
|
4781
4782
|
|
4782
4783
|
|
4783
4784
|
class DynamicObjMarshaler(ObjMarshaler):
|
4784
|
-
def marshal(self, o: ta.Any,
|
4785
|
-
return marshal_obj(o)
|
4785
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4786
|
+
return ctx.manager.marshal_obj(o, opts=ctx.options)
|
4786
4787
|
|
4787
|
-
def unmarshal(self, o: ta.Any,
|
4788
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4788
4789
|
return o
|
4789
4790
|
|
4790
4791
|
|
@@ -4792,10 +4793,10 @@ class DynamicObjMarshaler(ObjMarshaler):
|
|
4792
4793
|
class Base64ObjMarshaler(ObjMarshaler):
|
4793
4794
|
ty: type
|
4794
4795
|
|
4795
|
-
def marshal(self, o: ta.Any,
|
4796
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4796
4797
|
return base64.b64encode(o).decode('ascii')
|
4797
4798
|
|
4798
|
-
def unmarshal(self, o: ta.Any,
|
4799
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4799
4800
|
return self.ty(base64.b64decode(o))
|
4800
4801
|
|
4801
4802
|
|
@@ -4803,25 +4804,25 @@ class Base64ObjMarshaler(ObjMarshaler):
|
|
4803
4804
|
class BytesSwitchedObjMarshaler(ObjMarshaler):
|
4804
4805
|
m: ObjMarshaler
|
4805
4806
|
|
4806
|
-
def marshal(self, o: ta.Any,
|
4807
|
-
if
|
4807
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4808
|
+
if ctx.options.raw_bytes:
|
4808
4809
|
return o
|
4809
|
-
return self.m.marshal(o,
|
4810
|
+
return self.m.marshal(o, ctx)
|
4810
4811
|
|
4811
|
-
def unmarshal(self, o: ta.Any,
|
4812
|
-
if
|
4812
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4813
|
+
if ctx.options.raw_bytes:
|
4813
4814
|
return o
|
4814
|
-
return self.m.unmarshal(o,
|
4815
|
+
return self.m.unmarshal(o, ctx)
|
4815
4816
|
|
4816
4817
|
|
4817
4818
|
@dc.dataclass(frozen=True)
|
4818
4819
|
class EnumObjMarshaler(ObjMarshaler):
|
4819
4820
|
ty: type
|
4820
4821
|
|
4821
|
-
def marshal(self, o: ta.Any,
|
4822
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4822
4823
|
return o.name
|
4823
4824
|
|
4824
|
-
def unmarshal(self, o: ta.Any,
|
4825
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4825
4826
|
return self.ty.__members__[o] # type: ignore
|
4826
4827
|
|
4827
4828
|
|
@@ -4829,15 +4830,15 @@ class EnumObjMarshaler(ObjMarshaler):
|
|
4829
4830
|
class OptionalObjMarshaler(ObjMarshaler):
|
4830
4831
|
item: ObjMarshaler
|
4831
4832
|
|
4832
|
-
def marshal(self, o: ta.Any,
|
4833
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4833
4834
|
if o is None:
|
4834
4835
|
return None
|
4835
|
-
return self.item.marshal(o,
|
4836
|
+
return self.item.marshal(o, ctx)
|
4836
4837
|
|
4837
|
-
def unmarshal(self, o: ta.Any,
|
4838
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4838
4839
|
if o is None:
|
4839
4840
|
return None
|
4840
|
-
return self.item.unmarshal(o,
|
4841
|
+
return self.item.unmarshal(o, ctx)
|
4841
4842
|
|
4842
4843
|
|
4843
4844
|
@dc.dataclass(frozen=True)
|
@@ -4846,11 +4847,11 @@ class MappingObjMarshaler(ObjMarshaler):
|
|
4846
4847
|
km: ObjMarshaler
|
4847
4848
|
vm: ObjMarshaler
|
4848
4849
|
|
4849
|
-
def marshal(self, o: ta.Any,
|
4850
|
-
return {self.km.marshal(k,
|
4850
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4851
|
+
return {self.km.marshal(k, ctx): self.vm.marshal(v, ctx) for k, v in o.items()}
|
4851
4852
|
|
4852
|
-
def unmarshal(self, o: ta.Any,
|
4853
|
-
return self.ty((self.km.unmarshal(k,
|
4853
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4854
|
+
return self.ty((self.km.unmarshal(k, ctx), self.vm.unmarshal(v, ctx)) for k, v in o.items())
|
4854
4855
|
|
4855
4856
|
|
4856
4857
|
@dc.dataclass(frozen=True)
|
@@ -4858,11 +4859,11 @@ class IterableObjMarshaler(ObjMarshaler):
|
|
4858
4859
|
ty: type
|
4859
4860
|
item: ObjMarshaler
|
4860
4861
|
|
4861
|
-
def marshal(self, o: ta.Any,
|
4862
|
-
return [self.item.marshal(e,
|
4862
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4863
|
+
return [self.item.marshal(e, ctx) for e in o]
|
4863
4864
|
|
4864
|
-
def unmarshal(self, o: ta.Any,
|
4865
|
-
return self.ty(self.item.unmarshal(e,
|
4865
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4866
|
+
return self.ty(self.item.unmarshal(e, ctx) for e in o)
|
4866
4867
|
|
4867
4868
|
|
4868
4869
|
@dc.dataclass(frozen=True)
|
@@ -4871,11 +4872,18 @@ class DataclassObjMarshaler(ObjMarshaler):
|
|
4871
4872
|
fs: ta.Mapping[str, ObjMarshaler]
|
4872
4873
|
nonstrict: bool = False
|
4873
4874
|
|
4874
|
-
def marshal(self, o: ta.Any,
|
4875
|
-
return {
|
4875
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4876
|
+
return {
|
4877
|
+
k: m.marshal(getattr(o, k), ctx)
|
4878
|
+
for k, m in self.fs.items()
|
4879
|
+
}
|
4876
4880
|
|
4877
|
-
def unmarshal(self, o: ta.Any,
|
4878
|
-
return self.ty(**{
|
4881
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4882
|
+
return self.ty(**{
|
4883
|
+
k: self.fs[k].unmarshal(v, ctx)
|
4884
|
+
for k, v in o.items()
|
4885
|
+
if not (self.nonstrict or ctx.options.nonstrict_dataclasses) or k in self.fs
|
4886
|
+
})
|
4879
4887
|
|
4880
4888
|
|
4881
4889
|
@dc.dataclass(frozen=True)
|
@@ -4895,50 +4903,50 @@ class PolymorphicObjMarshaler(ObjMarshaler):
|
|
4895
4903
|
{i.tag: i for i in impls},
|
4896
4904
|
)
|
4897
4905
|
|
4898
|
-
def marshal(self, o: ta.Any,
|
4906
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4899
4907
|
impl = self.impls_by_ty[type(o)]
|
4900
|
-
return {impl.tag: impl.m.marshal(o,
|
4908
|
+
return {impl.tag: impl.m.marshal(o, ctx)}
|
4901
4909
|
|
4902
|
-
def unmarshal(self, o: ta.Any,
|
4910
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4903
4911
|
[(t, v)] = o.items()
|
4904
4912
|
impl = self.impls_by_tag[t]
|
4905
|
-
return impl.m.unmarshal(v,
|
4913
|
+
return impl.m.unmarshal(v, ctx)
|
4906
4914
|
|
4907
4915
|
|
4908
4916
|
@dc.dataclass(frozen=True)
|
4909
4917
|
class DatetimeObjMarshaler(ObjMarshaler):
|
4910
4918
|
ty: type
|
4911
4919
|
|
4912
|
-
def marshal(self, o: ta.Any,
|
4920
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4913
4921
|
return o.isoformat()
|
4914
4922
|
|
4915
|
-
def unmarshal(self, o: ta.Any,
|
4923
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4916
4924
|
return self.ty.fromisoformat(o) # type: ignore
|
4917
4925
|
|
4918
4926
|
|
4919
4927
|
class DecimalObjMarshaler(ObjMarshaler):
|
4920
|
-
def marshal(self, o: ta.Any,
|
4928
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4921
4929
|
return str(check_isinstance(o, decimal.Decimal))
|
4922
4930
|
|
4923
|
-
def unmarshal(self, v: ta.Any,
|
4931
|
+
def unmarshal(self, v: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4924
4932
|
return decimal.Decimal(check_isinstance(v, str))
|
4925
4933
|
|
4926
4934
|
|
4927
4935
|
class FractionObjMarshaler(ObjMarshaler):
|
4928
|
-
def marshal(self, o: ta.Any,
|
4936
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4929
4937
|
fr = check_isinstance(o, fractions.Fraction)
|
4930
4938
|
return [fr.numerator, fr.denominator]
|
4931
4939
|
|
4932
|
-
def unmarshal(self, v: ta.Any,
|
4940
|
+
def unmarshal(self, v: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4933
4941
|
num, denom = check_isinstance(v, list)
|
4934
4942
|
return fractions.Fraction(num, denom)
|
4935
4943
|
|
4936
4944
|
|
4937
4945
|
class UuidObjMarshaler(ObjMarshaler):
|
4938
|
-
def marshal(self, o: ta.Any,
|
4946
|
+
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4939
4947
|
return str(o)
|
4940
4948
|
|
4941
|
-
def unmarshal(self, o: ta.Any,
|
4949
|
+
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
4942
4950
|
return uuid.UUID(o)
|
4943
4951
|
|
4944
4952
|
|
@@ -5099,6 +5107,12 @@ class ObjMarshalerManager:
|
|
5099
5107
|
|
5100
5108
|
#
|
5101
5109
|
|
5110
|
+
def _make_context(self, opts: ta.Optional[ObjMarshalOptions]) -> 'ObjMarshalContext':
|
5111
|
+
return ObjMarshalContext(
|
5112
|
+
options=opts or self._default_options,
|
5113
|
+
manager=self,
|
5114
|
+
)
|
5115
|
+
|
5102
5116
|
def marshal_obj(
|
5103
5117
|
self,
|
5104
5118
|
o: ta.Any,
|
@@ -5106,7 +5120,7 @@ class ObjMarshalerManager:
|
|
5106
5120
|
opts: ta.Optional[ObjMarshalOptions] = None,
|
5107
5121
|
) -> ta.Any:
|
5108
5122
|
m = self.get_obj_marshaler(ty if ty is not None else type(o))
|
5109
|
-
return m.marshal(o,
|
5123
|
+
return m.marshal(o, self._make_context(opts))
|
5110
5124
|
|
5111
5125
|
def unmarshal_obj(
|
5112
5126
|
self,
|
@@ -5115,7 +5129,7 @@ class ObjMarshalerManager:
|
|
5115
5129
|
opts: ta.Optional[ObjMarshalOptions] = None,
|
5116
5130
|
) -> T:
|
5117
5131
|
m = self.get_obj_marshaler(ty)
|
5118
|
-
return m.unmarshal(o,
|
5132
|
+
return m.unmarshal(o, self._make_context(opts))
|
5119
5133
|
|
5120
5134
|
def roundtrip_obj(
|
5121
5135
|
self,
|
@@ -5130,6 +5144,12 @@ class ObjMarshalerManager:
|
|
5130
5144
|
return u
|
5131
5145
|
|
5132
5146
|
|
5147
|
+
@dc.dataclass(frozen=True)
|
5148
|
+
class ObjMarshalContext:
|
5149
|
+
options: ObjMarshalOptions
|
5150
|
+
manager: ObjMarshalerManager
|
5151
|
+
|
5152
|
+
|
5133
5153
|
##
|
5134
5154
|
|
5135
5155
|
|
@@ -6125,7 +6145,7 @@ class HasDispatchers(abc.ABC):
|
|
6125
6145
|
raise NotImplementedError
|
6126
6146
|
|
6127
6147
|
|
6128
|
-
class ProcessDispatcher(
|
6148
|
+
class ProcessDispatcher(FdioHandler, abc.ABC):
|
6129
6149
|
@property
|
6130
6150
|
@abc.abstractmethod
|
6131
6151
|
def channel(self) -> ProcessOutputChannel:
|
@@ -6255,7 +6275,7 @@ class ProcessGroup(
|
|
6255
6275
|
# ../../../omlish/lite/fdio/corohttp.py
|
6256
6276
|
|
6257
6277
|
|
6258
|
-
class
|
6278
|
+
class CoroHttpServerConnectionFdioHandler(SocketFdioHandler):
|
6259
6279
|
def __init__(
|
6260
6280
|
self,
|
6261
6281
|
addr: SocketAddress,
|
@@ -6384,8 +6404,8 @@ class CoroHttpServerConnectionFdIoHandler(SocketFdIoHandler):
|
|
6384
6404
|
# ../dispatchers.py
|
6385
6405
|
|
6386
6406
|
|
6387
|
-
class Dispatchers(KeyedCollection[Fd,
|
6388
|
-
def _key(self, v:
|
6407
|
+
class Dispatchers(KeyedCollection[Fd, FdioHandler]):
|
6408
|
+
def _key(self, v: FdioHandler) -> Fd:
|
6389
6409
|
return Fd(v.fd())
|
6390
6410
|
|
6391
6411
|
#
|
@@ -7180,7 +7200,7 @@ class IoManager(HasDispatchers):
|
|
7180
7200
|
def __init__(
|
7181
7201
|
self,
|
7182
7202
|
*,
|
7183
|
-
poller:
|
7203
|
+
poller: FdioPoller,
|
7184
7204
|
has_dispatchers_list: HasDispatchersList,
|
7185
7205
|
) -> None:
|
7186
7206
|
super().__init__()
|
@@ -7292,7 +7312,7 @@ class ProcessSpawning:
|
|
7292
7312
|
##
|
7293
7313
|
|
7294
7314
|
|
7295
|
-
class
|
7315
|
+
class SocketServerFdioHandler(SocketFdioHandler):
|
7296
7316
|
def __init__(
|
7297
7317
|
self,
|
7298
7318
|
addr: SocketAddress,
|
@@ -7339,9 +7359,9 @@ class HttpServer(HasDispatchers):
|
|
7339
7359
|
self._handler = handler.h
|
7340
7360
|
self._addr = addr.a
|
7341
7361
|
|
7342
|
-
self._server =
|
7362
|
+
self._server = SocketServerFdioHandler(self._addr, self._on_connect)
|
7343
7363
|
|
7344
|
-
self._conns: ta.List[
|
7364
|
+
self._conns: ta.List[CoroHttpServerConnectionFdioHandler] = []
|
7345
7365
|
|
7346
7366
|
exit_stack.enter_context(defer(self._server.close)) # noqa
|
7347
7367
|
|
@@ -7357,7 +7377,7 @@ class HttpServer(HasDispatchers):
|
|
7357
7377
|
])
|
7358
7378
|
|
7359
7379
|
def _on_connect(self, sock: socket.socket, addr: SocketAddress) -> None:
|
7360
|
-
conn =
|
7380
|
+
conn = CoroHttpServerConnectionFdioHandler(
|
7361
7381
|
addr,
|
7362
7382
|
sock,
|
7363
7383
|
self._handler,
|
@@ -8106,7 +8126,7 @@ class ProcessSpawningImpl(ProcessSpawning):
|
|
8106
8126
|
return exe, args
|
8107
8127
|
|
8108
8128
|
def _make_dispatchers(self, pipes: ProcessPipes) -> Dispatchers:
|
8109
|
-
dispatchers: ta.List[
|
8129
|
+
dispatchers: ta.List[FdioHandler] = []
|
8110
8130
|
|
8111
8131
|
if pipes.stdout is not None:
|
8112
8132
|
dispatchers.append(check_isinstance(self._output_dispatcher_factory(
|
@@ -8296,7 +8316,7 @@ class Supervisor:
|
|
8296
8316
|
self,
|
8297
8317
|
*,
|
8298
8318
|
config: ServerConfig,
|
8299
|
-
poller:
|
8319
|
+
poller: FdioPoller,
|
8300
8320
|
process_groups: ProcessGroupManager,
|
8301
8321
|
signal_handler: SignalHandler,
|
8302
8322
|
event_callbacks: EventCallbacks,
|
@@ -8536,8 +8556,8 @@ def waitpid() -> ta.Optional[WaitedPid]:
|
|
8536
8556
|
|
8537
8557
|
|
8538
8558
|
@dc.dataclass(frozen=True)
|
8539
|
-
class
|
8540
|
-
_poller:
|
8559
|
+
class _FdioPollerDaemonizeListener(DaemonizeListener):
|
8560
|
+
_poller: FdioPoller
|
8541
8561
|
|
8542
8562
|
def before_daemonize(self) -> None:
|
8543
8563
|
self._poller.close()
|
@@ -8609,14 +8629,14 @@ def bind_server(
|
|
8609
8629
|
#
|
8610
8630
|
|
8611
8631
|
poller_impl = next(filter(None, [
|
8612
|
-
|
8613
|
-
|
8614
|
-
|
8632
|
+
KqueueFdioPoller,
|
8633
|
+
PollFdioPoller,
|
8634
|
+
SelectFdioPoller,
|
8615
8635
|
]))
|
8616
8636
|
lst.extend([
|
8617
|
-
inj.bind(poller_impl, key=
|
8618
|
-
inj.bind(
|
8619
|
-
inj.bind(DaemonizeListener, array=True, to_key=
|
8637
|
+
inj.bind(poller_impl, key=FdioPoller, singleton=True),
|
8638
|
+
inj.bind(_FdioPollerDaemonizeListener, singleton=True),
|
8639
|
+
inj.bind(DaemonizeListener, array=True, to_key=_FdioPollerDaemonizeListener),
|
8620
8640
|
])
|
8621
8641
|
|
8622
8642
|
#
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# ruff: noqa: UP006 UP007
|
2
|
-
from omlish.lite.fdio.handlers import
|
2
|
+
from omlish.lite.fdio.handlers import FdioHandler
|
3
3
|
|
4
4
|
from .types import ProcessOutputDispatcher
|
5
5
|
from .utils.collections import KeyedCollection
|
6
6
|
from .utils.ostypes import Fd
|
7
7
|
|
8
8
|
|
9
|
-
class Dispatchers(KeyedCollection[Fd,
|
10
|
-
def _key(self, v:
|
9
|
+
class Dispatchers(KeyedCollection[Fd, FdioHandler]):
|
10
|
+
def _key(self, v: FdioHandler) -> Fd:
|
11
11
|
return Fd(v.fd())
|
12
12
|
|
13
13
|
#
|
ominfra/supervisor/http.py
CHANGED
@@ -6,8 +6,8 @@ import typing as ta
|
|
6
6
|
|
7
7
|
from omlish.lite.check import check_not_none
|
8
8
|
from omlish.lite.contextmanagers import defer
|
9
|
-
from omlish.lite.fdio.corohttp import
|
10
|
-
from omlish.lite.fdio.handlers import
|
9
|
+
from omlish.lite.fdio.corohttp import CoroHttpServerConnectionFdioHandler
|
10
|
+
from omlish.lite.fdio.handlers import SocketFdioHandler
|
11
11
|
from omlish.lite.http.handlers import HttpHandler
|
12
12
|
from omlish.lite.http.handlers import HttpHandlerRequest
|
13
13
|
from omlish.lite.http.handlers import HttpHandlerResponse
|
@@ -22,7 +22,7 @@ from .types import HasDispatchers
|
|
22
22
|
##
|
23
23
|
|
24
24
|
|
25
|
-
class
|
25
|
+
class SocketServerFdioHandler(SocketFdioHandler):
|
26
26
|
def __init__(
|
27
27
|
self,
|
28
28
|
addr: SocketAddress,
|
@@ -69,9 +69,9 @@ class HttpServer(HasDispatchers):
|
|
69
69
|
self._handler = handler.h
|
70
70
|
self._addr = addr.a
|
71
71
|
|
72
|
-
self._server =
|
72
|
+
self._server = SocketServerFdioHandler(self._addr, self._on_connect)
|
73
73
|
|
74
|
-
self._conns: ta.List[
|
74
|
+
self._conns: ta.List[CoroHttpServerConnectionFdioHandler] = []
|
75
75
|
|
76
76
|
exit_stack.enter_context(defer(self._server.close)) # noqa
|
77
77
|
|
@@ -87,7 +87,7 @@ class HttpServer(HasDispatchers):
|
|
87
87
|
])
|
88
88
|
|
89
89
|
def _on_connect(self, sock: socket.socket, addr: SocketAddress) -> None:
|
90
|
-
conn =
|
90
|
+
conn = CoroHttpServerConnectionFdioHandler(
|
91
91
|
addr,
|
92
92
|
sock,
|
93
93
|
self._handler,
|
ominfra/supervisor/inject.py
CHANGED
@@ -3,10 +3,10 @@ import contextlib
|
|
3
3
|
import dataclasses as dc
|
4
4
|
import typing as ta
|
5
5
|
|
6
|
-
from omlish.lite.fdio.kqueue import
|
7
|
-
from omlish.lite.fdio.pollers import
|
8
|
-
from omlish.lite.fdio.pollers import
|
9
|
-
from omlish.lite.fdio.pollers import
|
6
|
+
from omlish.lite.fdio.kqueue import KqueueFdioPoller # noqa
|
7
|
+
from omlish.lite.fdio.pollers import FdioPoller
|
8
|
+
from omlish.lite.fdio.pollers import PollFdioPoller # noqa
|
9
|
+
from omlish.lite.fdio.pollers import SelectFdioPoller
|
10
10
|
from omlish.lite.inject import InjectorBindingOrBindings
|
11
11
|
from omlish.lite.inject import InjectorBindings
|
12
12
|
from omlish.lite.inject import inj
|
@@ -46,8 +46,8 @@ from .utils.users import get_user
|
|
46
46
|
|
47
47
|
|
48
48
|
@dc.dataclass(frozen=True)
|
49
|
-
class
|
50
|
-
_poller:
|
49
|
+
class _FdioPollerDaemonizeListener(DaemonizeListener):
|
50
|
+
_poller: FdioPoller
|
51
51
|
|
52
52
|
def before_daemonize(self) -> None:
|
53
53
|
self._poller.close()
|
@@ -119,14 +119,14 @@ def bind_server(
|
|
119
119
|
#
|
120
120
|
|
121
121
|
poller_impl = next(filter(None, [
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
KqueueFdioPoller,
|
123
|
+
PollFdioPoller,
|
124
|
+
SelectFdioPoller,
|
125
125
|
]))
|
126
126
|
lst.extend([
|
127
|
-
inj.bind(poller_impl, key=
|
128
|
-
inj.bind(
|
129
|
-
inj.bind(DaemonizeListener, array=True, to_key=
|
127
|
+
inj.bind(poller_impl, key=FdioPoller, singleton=True),
|
128
|
+
inj.bind(_FdioPollerDaemonizeListener, singleton=True),
|
129
|
+
inj.bind(DaemonizeListener, array=True, to_key=_FdioPollerDaemonizeListener),
|
130
130
|
])
|
131
131
|
|
132
132
|
#
|
ominfra/supervisor/io.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# ruff: noqa: UP006 UP007
|
2
2
|
import typing as ta
|
3
3
|
|
4
|
-
from omlish.lite.fdio.pollers import
|
4
|
+
from omlish.lite.fdio.pollers import FdioPoller
|
5
5
|
from omlish.lite.logs import log
|
6
6
|
|
7
7
|
from .dispatchers import Dispatchers
|
@@ -20,7 +20,7 @@ class IoManager(HasDispatchers):
|
|
20
20
|
def __init__(
|
21
21
|
self,
|
22
22
|
*,
|
23
|
-
poller:
|
23
|
+
poller: FdioPoller,
|
24
24
|
has_dispatchers_list: HasDispatchersList,
|
25
25
|
) -> None:
|
26
26
|
super().__init__()
|