Skip to content

Remoter.refresh accumulates idle timeout from the previous deadline #169

Description

@kentbull

Problem

Remoter.refresh() currently calls Tymer.restart(). restart() advances from the previous deadline, which preserves periodic cadence but does not reset an inactivity timeout.

Successful Remoter reads and writes call refresh(). Each call therefore adds another timeout duration to the previous deadline instead of setting it to current tyme + tymeout. This can grant an active connection increasing amounts of future idle time and delay stale-connection cleanup.

Reproduction

def test_remoter_refresh_resets_idle_tymeout_from_current_tyme():
    tymist = tyming.Tymist()
    remoter = tcp.Remoter(
        tymth=tymist.tymen(),
        ha=("127.0.0.1", 56000),
        ca=("127.0.0.1", 56001),
        cs=None,
        tymeout=1.0,
    )

    tymist.tick(tock=0.75)
    remoter.refresh()
    remoter.refresh()

    assert remoter.tymer.remaining == pytest.approx(1.0)

Run:

pytest -q tests/core/tcp/test_tcp.py::test_remoter_refresh_resets_idle_tymeout_from_current_tyme

Current result:

Obtained: 2.25
Expected: 1.0

A single refresh is already incorrect: at tyme == 0.75, it leaves 1.25 seconds remaining instead of resetting the remaining idle timeout to 1.0. Repeated refreshes accumulate the error.

Expected behavior

Refreshing an idle timeout should set its deadline relative to the current scheduler tyme. For a Remoter without an injected tyme base, refreshing should remain a no-op because no inactivity interval can be measured.

Related pull requests

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions