ominfra 0.0.0.dev130__py3-none-any.whl → 0.0.0.dev132__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.
@@ -182,11 +182,29 @@ class Supervisor:
182
182
  #
183
183
 
184
184
  def _run_once(self) -> None:
185
- now = time.time()
186
- self._poll()
187
- log.info(f'Poll took {time.time() - now}') # noqa
185
+ if self._states.state < SupervisorState.RUNNING:
186
+ if not self._stopping:
187
+ # first time, set the stopping flag, do a notification and set stop_groups
188
+ self._stopping = True
189
+ self._stop_groups = sorted(self._process_groups)
190
+ self._event_callbacks.notify(SupervisorStoppingEvent())
191
+
192
+ self._ordered_stop_groups_phase_1()
193
+
194
+ if not self.shutdown_report():
195
+ # if there are no unstopped processes (we're done killing everything), it's OK to shutdown or reload
196
+ raise ExitNow
197
+
198
+ self._io.poll()
199
+
200
+ for group in sorted(self._process_groups):
201
+ for process in group:
202
+ process.transition()
203
+
188
204
  self._reap()
205
+
189
206
  self._signal_handler.handle_signals()
207
+
190
208
  self._tick()
191
209
 
192
210
  if self._states.state < SupervisorState.RUNNING:
@@ -208,38 +226,18 @@ class Supervisor:
208
226
  # down, so push it back on to the end of the stop group queue
209
227
  self._stop_groups.append(group)
210
228
 
211
- def _poll(self) -> None:
212
- sorted_groups = list(self._process_groups)
213
- sorted_groups.sort()
214
-
215
- if self._states.state < SupervisorState.RUNNING:
216
- if not self._stopping:
217
- # first time, set the stopping flag, do a notification and set stop_groups
218
- self._stopping = True
219
- self._stop_groups = sorted_groups[:]
220
- self._event_callbacks.notify(SupervisorStoppingEvent())
221
-
222
- self._ordered_stop_groups_phase_1()
223
-
224
- if not self.shutdown_report():
225
- # if there are no unstopped processes (we're done killing everything), it's OK to shutdown or reload
226
- raise ExitNow
227
-
228
- self._io.poll()
229
-
230
- for group in sorted_groups:
231
- for process in group:
232
- process.transition()
229
+ #
233
230
 
234
231
  def _reap(self, *, once: bool = False, depth: int = 0) -> None:
235
232
  if depth >= 100:
236
233
  return
237
234
 
238
235
  wp = waitpid()
239
- log.info(f'Waited pid: {wp}') # noqa
236
+
240
237
  if wp is None or not wp.pid:
241
238
  return
242
239
 
240
+ log.info(f'Waited pid: {wp}') # noqa
243
241
  process = self._pid_history.get(wp.pid, None)
244
242
  if process is None:
245
243
  _, msg = decode_wait_status(wp.sts)
@@ -252,6 +250,8 @@ class Supervisor:
252
250
  # keep reaping until no more kids to reap, but don't recurse infinitely
253
251
  self._reap(once=False, depth=depth + 1)
254
252
 
253
+ #
254
+
255
255
  def _tick(self, now: ta.Optional[float] = None) -> None:
256
256
  """Send one or more 'tick' events when the timeslice related to the period for the event type rolls over"""
257
257
 
@@ -282,7 +282,7 @@ class WaitedPid(ta.NamedTuple):
282
282
 
283
283
 
284
284
  def waitpid() -> ta.Optional[WaitedPid]:
285
- # Need pthread_sigmask here to avoid concurrent sigchld, but Python doesn't offer in Python < 3.4. There is
285
+ # Need pthread_sigmask here to avoid concurrent sigchld, but Python doesn't offer in Python < 3.4. There is
286
286
  # still a race condition here; we can get a sigchld while we're sitting in the waitpid call. However, AFAICT, if
287
287
  # waitpid is interrupted by SIGCHLD, as long as we call waitpid again (which happens every so often during the
288
288
  # normal course in the mainloop), we'll eventually reap the child that we tried to reap during the interrupted
@@ -7,6 +7,7 @@ from omlish.lite.fdio.handlers import FdIoHandler
7
7
 
8
8
  from .configs import ProcessConfig
9
9
  from .configs import ProcessGroupConfig
10
+ from .events import ProcessOutputChannel
10
11
  from .states import ProcessState
11
12
  from .states import SupervisorState
12
13
  from .utils.collections import KeyedCollectionAccessors
@@ -71,7 +72,7 @@ class HasDispatchers(abc.ABC):
71
72
  class ProcessDispatcher(FdIoHandler, abc.ABC):
72
73
  @property
73
74
  @abc.abstractmethod
74
- def channel(self) -> str:
75
+ def channel(self) -> ProcessOutputChannel:
75
76
  raise NotImplementedError
76
77
 
77
78
  @property
@@ -21,7 +21,7 @@ def decode_wait_status(sts: int) -> ta.Tuple[Rc, str]:
21
21
  Decode the status returned by wait() or waitpid().
22
22
 
23
23
  Return a tuple (exitstatus, message) where exitstatus is the exit status, or -1 if the process was killed by a
24
- signal; and message is a message telling what happened. It is the caller's responsibility to display the message.
24
+ signal; and message is a message telling what happened. It is the caller's responsibility to display the message.
25
25
  """
26
26
 
27
27
  if os.WIFEXITED(sts):
@@ -62,8 +62,8 @@ def strip_escapes(s: bytes) -> bytes:
62
62
 
63
63
 
64
64
  class SuffixMultiplier:
65
- # d is a dictionary of suffixes to integer multipliers. If no suffixes match, default is the multiplier. Matches
66
- # are case insensitive. Return values are in the fundamental unit.
65
+ # d is a dictionary of suffixes to integer multipliers. If no suffixes match, default is the multiplier. Matches are
66
+ # case insensitive. Return values are in the fundamental unit.
67
67
  def __init__(self, d, default=1):
68
68
  super().__init__()
69
69
  self._d = d
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev130
3
+ Version: 0.0.0.dev132
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.dev130
16
- Requires-Dist: omlish==0.0.0.dev130
15
+ Requires-Dist: omdev==0.0.0.dev132
16
+ Requires-Dist: omlish==0.0.0.dev132
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -22,7 +22,7 @@ ominfra/clouds/aws/journald2aws/poster.py,sha256=hz1XuctW8GtLmfjhRvCFY6py52D4BzX
22
22
  ominfra/clouds/gcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  ominfra/clouds/gcp/auth.py,sha256=3PyfRJNgajjMqJFem3SKui0CqGeHEsZlvbRhuxFcZG8,1348
24
24
  ominfra/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- ominfra/deploy/_executor.py,sha256=3h7ViDW9WtF__sI_qK88SUgldalqdnpf5AlJGbCF9TY,35361
25
+ ominfra/deploy/_executor.py,sha256=4i5JP4tiF-MJQHxwstja4tRoYprnAMyzGd9f_az3r98,35355
26
26
  ominfra/deploy/configs.py,sha256=qi0kwT7G2NH7dXLOQic-u6R3yeadup_QtvrjwWIggbM,435
27
27
  ominfra/deploy/remote.py,sha256=6ACmpXU1uBdyGs3Xsp97ktKFq30cJlzN9LRWNUWlGY4,2144
28
28
  ominfra/deploy/executor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
@@ -37,7 +37,7 @@ ominfra/deploy/executor/concerns/systemd.py,sha256=MtsSEToEa1HNouern_JukcYTnypw_
37
37
  ominfra/deploy/executor/concerns/user.py,sha256=j5LDfQXquIp-eEM7t6aShsrYoQrM_ILXZycTmTcRVxA,686
38
38
  ominfra/deploy/executor/concerns/venv.py,sha256=jbRriqJHO4r9Zyo5Hfl_qVmcU6Qm6UgrouBroKcPn2g,775
39
39
  ominfra/deploy/poly/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
40
- ominfra/deploy/poly/_main.py,sha256=RyuYQCytPyRqBx8qtzrMiP8xa9C9E3nF2fpLTubt5v8,24180
40
+ ominfra/deploy/poly/_main.py,sha256=fqlcDbbfY6gmebcO9BMWD9sz6V6_gxFTQr194xi69N4,24174
41
41
  ominfra/deploy/poly/base.py,sha256=1dGuzWxi2Z6Hm6-YlkVxPk9r3In2aCJ0p8lGR-QQI_s,4166
42
42
  ominfra/deploy/poly/configs.py,sha256=9bzWdbxhOk_Q4KokDjmRz254KHnUU71Vl1frLlhQyU4,584
43
43
  ominfra/deploy/poly/deploy.py,sha256=tMYKslXLjstcv86siRt5j37USsS0Wd6lsfeGRE26zio,544
@@ -56,56 +56,56 @@ ominfra/journald/tailer.py,sha256=5abcFMfgi7fnY9ZEQe2ZVobaJxjQkeu6d9Kagw33a1w,33
56
56
  ominfra/manage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  ominfra/manage/manage.py,sha256=BttL8LFEknHZE_h2Pt5dAqbfUkv6qy43WI0raXBZ1a8,151
58
58
  ominfra/pyremote/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
- ominfra/pyremote/_runcommands.py,sha256=TfO2cwXbw_1T-c_NDM7K8gWYJbU20Y3k9qEIOM3S6BI,29194
59
+ ominfra/pyremote/_runcommands.py,sha256=RKNvaHje-QGpvwwmFQ6OfEn3eEJ2c6zVUBYnDo2RV9U,29188
60
60
  ominfra/pyremote/bootstrap.py,sha256=RvMO3YGaN1E4sgUi1JEtiPak8cjvqtc_vRCq1yqbeZg,3370
61
61
  ominfra/pyremote/runcommands.py,sha256=bviS0_TDIoZVAe4h-_iavbvJtVSFu8lnk7fQ5iasCWE,1571
62
62
  ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
- ominfra/scripts/journald2aws.py,sha256=FmjNwUPQDCOmIbUxwkN7mNHATf_lXf1uwp0ST71IHFA,131405
64
- ominfra/scripts/supervisor.py,sha256=DHvE1h2s57IvHEIZnqsmhx7BrrO20Qbd21IwkQGasmM,242622
63
+ ominfra/scripts/journald2aws.py,sha256=o6WgI9R3MXdH4-BKUYAK2pcu3E5T0GAl5pggzR4Lhrk,131537
64
+ ominfra/scripts/supervisor.py,sha256=_n84Wz_L1QZmOTD3S9PGecmSt6OUPCO6K9lOu4VoByE,245533
65
65
  ominfra/supervisor/LICENSE.txt,sha256=yvqaMNsDhWxziHa9ien6qCW1SkZv-DQlAg96XjfSee8,1746
66
66
  ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
67
67
  ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
68
- ominfra/supervisor/configs.py,sha256=AhBlbifwDXc0acEhcbdv9jphJL-SBFODFDAWDVckzAE,3945
68
+ ominfra/supervisor/configs.py,sha256=OPtiL5_SjBYQ9xDqMgZvjoXgpleTxv4d3C4fD1X2Dz0,3966
69
69
  ominfra/supervisor/dispatchers.py,sha256=dfjog5PyVAJaFzgFI0tpy38ZgDiFrewMjVi21ksrlAg,1007
70
- ominfra/supervisor/dispatchersimpl.py,sha256=k86MSDxIHInOBopYehNuCDcSM_QsxrrGuME0UjnSs_o,11249
71
- ominfra/supervisor/events.py,sha256=w3HQFrq-SuroYWoQfNFYeU1phnTvHTgsAqA6TGtAafI,6593
70
+ ominfra/supervisor/dispatchersimpl.py,sha256=q3dEyOHWTPKm28nmAGisjgIW1BX6O3-SzbYa7nWuTEs,11349
71
+ ominfra/supervisor/events.py,sha256=XGrtzHr1xm0dwjz329fn9eR0_Ap-LQL6Sk8LJ8eVDEo,6692
72
72
  ominfra/supervisor/exceptions.py,sha256=Qbu211H3CLlSmi9LsSikOwrcL5HgJP9ugvcKWlGTAoI,750
73
73
  ominfra/supervisor/groups.py,sha256=MBbsbt8Zh_WEYkGOr1KXa82gnPVw9wPB2lAnqhugXSc,2457
74
74
  ominfra/supervisor/groupsimpl.py,sha256=nIrW4SmB0W6c2jOR_HhkfVcH4eHyLZnG1FJ0MCzc6mQ,2292
75
- ominfra/supervisor/http.py,sha256=y0tos6zbb4k-WvNQXlgAeK1qi5mKXkyXO9bVJt4OXew,3227
76
- ominfra/supervisor/inject.py,sha256=onKUudx5eBbNuXwEqeiaVIIA3ZbpUSDiEAKg9GBiWG8,4514
77
- ominfra/supervisor/io.py,sha256=2NO4BYC-PznIrJpTFxN8UEAhd_codfNm_HI424gYQ3c,3294
78
- ominfra/supervisor/main.py,sha256=ebe7skFPfwXV2meMVRndhuLZmz-LiuHH1x1CgiarR0o,4132
79
- ominfra/supervisor/pipes.py,sha256=XrJ9lD04tPdzZD3xhhYKxpBKHWhZ0Ii315E78bgj7ws,2233
80
- ominfra/supervisor/privileges.py,sha256=bO7rJGT7cMOBALK_4D4NiQnOS5dOYb14Sz66R-ymG24,2071
75
+ ominfra/supervisor/http.py,sha256=WC7TD6ECD28GU83sUAd6Xau2pvYyZZmmFDgL-E4_Jd0,3472
76
+ ominfra/supervisor/inject.py,sha256=cH7ZV5KnOlHh90_S6YWlJsJCfM9Ve956GzEAhl4arx8,4627
77
+ ominfra/supervisor/io.py,sha256=_G66luJDF-i1JPM-qJiREMdmHk2ul7n-kjr7ex1sF6s,3200
78
+ ominfra/supervisor/main.py,sha256=oqaWOcnHJgaxNhjyphPgjaNjHPjDcx7kzYMjtZpwSxE,4253
79
+ ominfra/supervisor/pipes.py,sha256=2ZihNTnRNjnIPOtPbm3_pyqO15f7BNs7WnNtO5V8ahM,2231
80
+ ominfra/supervisor/privileges.py,sha256=kaRTHI7XjqzxEWCeHp3_0J0Vc4gSPugRbXEwxuw6MYE,2054
81
81
  ominfra/supervisor/process.py,sha256=UaubVxsxVqDnbuWVpTH0DTGbJGLO0vGJ9mNcvy2kCXM,217
82
- ominfra/supervisor/processimpl.py,sha256=vpyRVOYV8_AW5eCtgAa2LKWyW9FiqA5bKmBqF1KYE5c,18715
82
+ ominfra/supervisor/processimpl.py,sha256=BcvX-e03qjFSUogDUVmevwyizXS3kss3JY1QkHWjKWE,18689
83
83
  ominfra/supervisor/setup.py,sha256=7HwwwI-WT_Z0WjZ9_l5Orr4K298nKKhQ1f_ZgGsi9TU,622
84
- ominfra/supervisor/setupimpl.py,sha256=S_YgCH3XzLsFIAriJROvDMUDh7OzVVJoxzEzCkbb4g4,9648
84
+ ominfra/supervisor/setupimpl.py,sha256=88h3oYsdJ0LAo7sZZZGRQti14oQay3b-0Vd_h3Cl108,9638
85
85
  ominfra/supervisor/signals.py,sha256=jY52naUifcAjd6nICTP1ZW3IQSPsHB4cvbsJo8_QV_U,2196
86
86
  ominfra/supervisor/spawning.py,sha256=i1k3tmqWyU-KIN7kel-JVxTVGnLiTIVmZzlstJSZpjM,622
87
- ominfra/supervisor/spawningimpl.py,sha256=Med8UJH7vP3IaihTJIaqfndhB5mD5wht6Feim674HKs,11161
88
- ominfra/supervisor/states.py,sha256=9yoNOSwalRcKEnCP9zG6tVS0oivo5tCeuH6AaaW7Jpc,890
89
- ominfra/supervisor/supervisor.py,sha256=XiLVq8qMLKGR50yTgW5njtqVkZCupf-cXDjmh7bJtXQ,9515
90
- ominfra/supervisor/types.py,sha256=RamAYEF3fISfKwlIMRleLOFuKVWrxjQJGI6p76jK03c,3959
87
+ ominfra/supervisor/spawningimpl.py,sha256=Pkp6mefJhOGCCj5T2I1jXEsVp15g9KMKbANYgoX-ws8,11162
88
+ ominfra/supervisor/states.py,sha256=x1trJQbItkSegOmotpn5YNcZMLbBL8I3GmhvFCQl4Oo,1400
89
+ ominfra/supervisor/supervisor.py,sha256=5V5DJHThPzJmctO4_UZV5-vx0ieT43TIcL_ZIl6T0xQ,9342
90
+ ominfra/supervisor/types.py,sha256=n4AILLzdeavM5ejOFKP-rPRNK87UV8aFyoeRKPVDxxg,4017
91
91
  ominfra/supervisor/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
92
  ominfra/supervisor/utils/collections.py,sha256=vcfmVYS4QngMdtEI1DvdRIcubmy55Wj40NCzW27_rIY,1361
93
93
  ominfra/supervisor/utils/diag.py,sha256=ujz4gkW7p3wmbaKFM8Hz5eHEwpoUkbB8JeDvcHilCz0,705
94
94
  ominfra/supervisor/utils/fds.py,sha256=lz8DWXzGYvu93dqhWK0WrhXrrJVQ_psoom4Nj_o8g2g,849
95
95
  ominfra/supervisor/utils/fs.py,sha256=ABbNcsCpzSXAvq_ZZSCj61mj5kGnVuC4spUmoWenlqw,1155
96
- ominfra/supervisor/utils/os.py,sha256=9fw--tpHOrSjGTCkUo1KRBgbGGxKW2va5xKw2cHwtRU,1096
96
+ ominfra/supervisor/utils/os.py,sha256=IZJ9mBV23CAI0hSBVQiyCNcf-sWqHAmjAW9bbsvKFao,1095
97
97
  ominfra/supervisor/utils/ostypes.py,sha256=B7VjwbzVesz9we9MztoSk8bH8sTxMIWtILy_Qde0G7w,164
98
98
  ominfra/supervisor/utils/signals.py,sha256=uZkTvissbtq7TlJD4MkTiL3F-zyWmAFUuWQtFjsf0MI,1474
99
- ominfra/supervisor/utils/strings.py,sha256=B0UOuVM_NIWmcznycmiEbwJ0lcoTGEd3Ir1AeLkBXeU,2478
99
+ ominfra/supervisor/utils/strings.py,sha256=gZOYiFI3ZQEMrXq6VlK2WadK12JPO6zYjPenq_OPcYU,2475
100
100
  ominfra/supervisor/utils/users.py,sha256=PRUhWy74WQCxix4BLNYcWW1i2mF1IyAxj1RzElnP4iM,1345
101
101
  ominfra/tailscale/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
102
102
  ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
103
103
  ominfra/tailscale/cli.py,sha256=DSGp4hn5xwOW-l_u_InKlSF6kIobxtUtVssf_73STs0,3567
104
104
  ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
105
105
  ominfra/tools/listresources.py,sha256=4qVg5txsb10EHhvqXXeM6gJ2jx9LbroEnPydDv1uXs0,6176
106
- ominfra-0.0.0.dev130.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
107
- ominfra-0.0.0.dev130.dist-info/METADATA,sha256=PjbMdzNCdOt4JYdmoDTM92oJu056qJOvTng2oncmCIU,731
108
- ominfra-0.0.0.dev130.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
109
- ominfra-0.0.0.dev130.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
110
- ominfra-0.0.0.dev130.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
111
- ominfra-0.0.0.dev130.dist-info/RECORD,,
106
+ ominfra-0.0.0.dev132.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
107
+ ominfra-0.0.0.dev132.dist-info/METADATA,sha256=vq41f4P1jKGnX9UuGdMibA-bayJhVbb8rk_vZQw0-r8,731
108
+ ominfra-0.0.0.dev132.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
109
+ ominfra-0.0.0.dev132.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
110
+ ominfra-0.0.0.dev132.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
111
+ ominfra-0.0.0.dev132.dist-info/RECORD,,