pytogo / portforward

Kubernetes Port-Forward Go-Edition For Python

Home Page:https://portforward.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Portforward crashes intermittently when portforwarding to same port repeatedly

drawal1 opened this issue · comments

  • portforward version: latest
  • Python version: 3.10.8
  • Operating System: Ubuntu Linux 20.04 LTS

Description

Running a pytest. portforward crashes intermittently. portforward crashes every time with exact same callstack signature if you manually bind the port before-hand so the port is already in use

What I Did

Ran a pytest that repeatedly uses portforward with the same port over and over. Saw intermittent crash when rerunning pytest
Manually forward port. Now portforward crashes EVERY TIME with exact same call stack. So..., port forward needs to check if port is already in use and wait OR abort displaying a proper error saying port is already in use 

Callstack with portforward tries to forward to a port already in use:
  File "/home/.../miniconda3/envs/sunshine/lib/python3.10/site-packages/portforward.py", line 92 in forward
  File "/home/.../miniconda3/envs/sunshine/lib/python3.10/contextlib.py", line 135 in __enter__

Hi @drawal1

the old behavior was to panic. I changed it and also test whether the port is available. The release for 0.4.3 will be today.