From f59a7fa878ba704d4123e250b3113acc6d7d2898 Mon Sep 17 00:00:00 2001 From: Tom Barbette Date: Sat, 16 Nov 2024 17:39:29 +0100 Subject: [PATCH] LocalExecutor: fix timeout expiring too soon --- npf/executor/localexecutor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/npf/executor/localexecutor.py b/npf/executor/localexecutor.py index ef3fbe54..8b1ad9cc 100644 --- a/npf/executor/localexecutor.py +++ b/npf/executor/localexecutor.py @@ -7,6 +7,7 @@ from typing import List from .executor import Executor from pathlib import Path +import time class LocalKiller: def __init__(self, pgpid): @@ -92,6 +93,7 @@ def exec(self, cmd : str, bin_paths : List[str]=[], flushing = False step = 0.2 + start = time.time() killer = LocalKiller(pgpid) if queue: queue.put(killer) @@ -115,8 +117,7 @@ def exec(self, cmd : str, bin_paths : List[str]=[], if timeout is not None: - timeout -= step - if timeout < 0: + if timeout < time.time() - start: raise TimeoutExpired(cmd, timeout) p.stdin.close()