Skip to content

Commit

Permalink
Sesnd SIGINT to end port-forward
Browse files Browse the repository at this point in the history
  • Loading branch information
ronenh committed Nov 26, 2024
1 parent 5054425 commit 5cee2e6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tools/ktest/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ def forward(self, svc: str, ports: Mapping[int, int]):
yield proc
finally:
logger.debug("terminating port-forward: %s", svc)
for stop in (proc.terminate, proc.kill):

def ctrl_c():
proc.send_signal(signal.SIGINT)

for stop in (ctrl_c, proc.terminate, proc.kill):
logger.debug("attempting to '%s' port-forward: %s", stop.__name__, svc)
stop()
try:
proc.communicate(timeout=3)
proc.communicate(timeout=15)
logger.debug("port-forward exited: %s", svc)
# wait for the port to become available again
time.sleep(3)
break
except subprocess.TimeoutExpired:
logger.info("timeout expired waiting for: %s", svc)
Expand Down

0 comments on commit 5cee2e6

Please sign in to comment.