Skip to content

Commit ccfbb1f

Browse files
committed
Move interrupt_handler processing to tasks
Signed-off-by: cyc60 <avsysoev60@gmail.com>
1 parent 8afe3bb commit ccfbb1f

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/commands/start.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -293,24 +293,23 @@ async def main() -> None:
293293

294294
logger.info('Started operator service')
295295
with InterruptHandler() as interrupt_handler:
296-
while not interrupt_handler.exit:
297-
tasks = [
298-
ValidatorsTask(
299-
keystores=keystores,
300-
remote_signer_config=remote_signer_config,
301-
deposit_data=deposit_data,
302-
).run(),
303-
ExitSignatureTask(
304-
keystores=keystores,
305-
remote_signer_config=remote_signer_config,
306-
).run(),
307-
MetricsTask().run(),
308-
WalletTask().run(),
309-
]
310-
if settings.harvest_vault:
311-
tasks.append(HarvestTask().run())
296+
tasks = [
297+
ValidatorsTask(
298+
keystores=keystores,
299+
remote_signer_config=remote_signer_config,
300+
deposit_data=deposit_data,
301+
).run(interrupt_handler),
302+
ExitSignatureTask(
303+
keystores=keystores,
304+
remote_signer_config=remote_signer_config,
305+
).run(interrupt_handler),
306+
MetricsTask().run(interrupt_handler),
307+
WalletTask().run(interrupt_handler),
308+
]
309+
if settings.harvest_vault:
310+
tasks.append(HarvestTask().run(interrupt_handler))
312311

313-
await asyncio.gather(*tasks)
312+
await asyncio.gather(*tasks)
314313

315314

316315
def log_start() -> None:

src/common/tasks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import logging
33
import time
44

5+
from sw_utils import InterruptHandler
6+
57
from src.common.utils import log_verbose
68
from src.config.settings import settings
79

@@ -12,8 +14,8 @@ class BaseTask:
1214
async def process_block(self):
1315
raise NotImplementedError
1416

15-
async def run(self):
16-
while True:
17+
async def run(self, interrupt_handler: InterruptHandler) -> None:
18+
while not interrupt_handler.exit:
1719
start_time = time.time()
1820
try:
1921
await self.process_block()

0 commit comments

Comments
 (0)