Skip to content

Commit

Permalink
LocalExecutor: fix timeout expiring too soon
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbette committed Nov 16, 2024
1 parent bda059d commit f59a7fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions npf/executor/localexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import List
from .executor import Executor
from pathlib import Path
import time

class LocalKiller:
def __init__(self, pgpid):
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit f59a7fa

Please sign in to comment.