is_alive opens a TCP connection even when the driver is closed, so every garbage-collected driver connects again #19

Closed
opened 2026-11-02 09:57:10 +00:00 by christianmanivong · 0 comments
Owner

What happens

ZyxelVMGDriver.is_alive() (napalm_zyxel/zyxel_driver.py:212) answers by opening a TCP connection to the gateway, whether or not the driver was opened, and also after close():

sock = socket.create_connection((self.hostname, self.port), timeout=5)

NAPALM's NetworkDriver.__del__ calls is_alive(). So every driver instance that is garbage-collected — in netOrk's workers after each poll — connects to the gateway once more and can block for up to 5 s in __del__. NAPALM's convention is that is_alive reports the state of the driver's own session; napalm-fritzbox returns early when its connection object is gone (fc is None).

Expected

is_alive() returns {"is_alive": False} without touching the network when the driver has no open session (never opened, or closed); with an open session it reports that session's state.

Test-first: a closed driver's is_alive() opens no socket.

Priority: P4 — a needless connection and up to 5 s stall per collected driver.

Found during the bug sweep of 2026-11-02 (#17).

## What happens `ZyxelVMGDriver.is_alive()` (`napalm_zyxel/zyxel_driver.py:212`) answers by opening a TCP connection to the gateway, whether or not the driver was opened, and also after `close()`: ```python sock = socket.create_connection((self.hostname, self.port), timeout=5) ``` NAPALM's `NetworkDriver.__del__` calls `is_alive()`. So every driver instance that is garbage-collected — in netOrk's workers after each poll — connects to the gateway once more and can block for up to 5 s in `__del__`. NAPALM's convention is that `is_alive` reports the state of the driver's own session; napalm-fritzbox returns early when its connection object is gone (`fc is None`). ## Expected `is_alive()` returns `{"is_alive": False}` without touching the network when the driver has no open session (never opened, or closed); with an open session it reports that session's state. Test-first: a closed driver's `is_alive()` opens no socket. Priority: P4 — a needless connection and up to 5 s stall per collected driver. Found during the bug sweep of 2026-11-02 (#17).
christianmanivong added the
prio
P4
bug
labels 2026-11-02 09:57:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-zyxel#19