Skip to content

Class peagen.tui.components.workers_view.WorkersView

peagen.tui.components.workers_view.WorkersView

Bases: DataTable

Display active pools and workers.

update_workers

update_workers(workers)

Refresh the table contents.

Source code in peagen/tui/components/workers_view.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def update_workers(self, workers: Mapping[str, Mapping[str, Any]]) -> None:
    """Refresh the table contents."""

    if not self.columns:
        self.add_columns(
            "Worker",
            "Pool",
            "URL",
            "Last Seen",
            "Advertises",
            "Handlers",
        )

    self.clear()
    for wid, info in workers.items():
        ts = info.get("last_seen")
        if isinstance(ts, datetime):
            ts_str = ts.isoformat(timespec="seconds")
        else:
            ts_str = str(ts) if ts is not None else ""

        self.add_row(
            wid,
            str(info.get("pool", "")),
            str(info.get("url", "")),
            ts_str,
            str(info.get("advertises", "")),
            ",".join(info.get("handlers", []))
            if isinstance(info.get("handlers"), list)
            else str(info.get("handlers", "")),
        )