is_alive() reports from the driver's own session, as in napalm-fritzbox (fc is None):
Without an open session (never opened, or after close(), i.e. _session or _sessionkey is unset) it returns {"is_alive": False} and makes no connection.
With an open session it reports whether the gateway still answers on its web port: the same TCP check as before, now only while there is a session to check.
The README row for is_alive says the same.
Why
is_alive() connected to the gateway in every case. NAPALM's NetworkDriver.__del__ asks it of every collected driver, so each one connected once more and could stall for up to five seconds in __del__. netOrk drops a driver after every poll.
Tests
Fixtures only (no device). tests/test_is_alive.py:
a never-opened and a closed driver: False, and socket.create_connection is not called (both failed before the change);
an open session with the port answering: True;
an open session with the connection refused: False.
The is_alive tests in test_zyxel.py now give the driver a mock session first. The session-wide no-socket guard from #18 stays green. pytest 70 passed, ruff format/check clean, mypy clean, napalm-standard check passes, napalm-standard ratchet within the baseline.
## What
`is_alive()` reports from the driver's own session, as in napalm-fritzbox (`fc is None`):
- Without an open session (never opened, or after `close()`, i.e. `_session` or `_sessionkey` is unset) it returns `{"is_alive": False}` and makes no connection.
- With an open session it reports whether the gateway still answers on its web port: the same TCP check as before, now only while there is a session to check.
The README row for `is_alive` says the same.
## Why
`is_alive()` connected to the gateway in every case. NAPALM's `NetworkDriver.__del__` asks it of every collected driver, so each one connected once more and could stall for up to five seconds in `__del__`. netOrk drops a driver after every poll.
## Tests
Fixtures only (no device). `tests/test_is_alive.py`:
- a never-opened and a closed driver: `False`, and `socket.create_connection` is not called (both failed before the change);
- an open session with the port answering: `True`;
- an open session with the connection refused: `False`.
The `is_alive` tests in `test_zyxel.py` now give the driver a mock session first. The session-wide no-socket guard from #18 stays green. pytest 70 passed, ruff format/check clean, mypy clean, `napalm-standard check` passes, `napalm-standard ratchet` within the baseline.
Closes #19
is_alive() opened a TCP connection to the gateway whether or not the
driver was opened, and after close() too. NAPALM's __del__ asks it of
every collected driver, so each one connected once more and could stall
for up to five seconds. Without an open session it now answers False
and connects nowhere; with one, it reports whether the gateway still
answers on its port.
Closes#19
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
is_alive()reports from the driver's own session, as in napalm-fritzbox (fc is None):close(), i.e._sessionor_sessionkeyis unset) it returns{"is_alive": False}and makes no connection.The README row for
is_alivesays the same.Why
is_alive()connected to the gateway in every case. NAPALM'sNetworkDriver.__del__asks it of every collected driver, so each one connected once more and could stall for up to five seconds in__del__. netOrk drops a driver after every poll.Tests
Fixtures only (no device).
tests/test_is_alive.py:False, andsocket.create_connectionis not called (both failed before the change);True;False.The
is_alivetests intest_zyxel.pynow give the driver a mock session first. The session-wide no-socket guard from #18 stays green. pytest 70 passed, ruff format/check clean, mypy clean,napalm-standard checkpasses,napalm-standard ratchetwithin the baseline.Closes #19