Skip to content

pb_client.service.Service.attach async

attach(*, hub_id=None, replay_bytes=0)

Follow everything a hub says, for the duration of the block.

Output, status and connection state arrive on one iterator, in the order they happened, which is what a terminal needs: a status saying the program stopped must not overtake the last thing it printed.

Attaching disturbs nobody. Several clients can watch one hub at once, and leaving does not stop what is running.

Parameters:

Name Type Description Default
hub_id str | None

Which hub, or None for the current one.

None
replay_bytes int

How much output from before attaching to deliver first. With a service that outlives commands, the usual thing is to start a program in one window and attach in another a moment later, and without this that program's first lines are lost every time.

0

Yields:

Type Description
AsyncGenerator[AsyncIterator[HubEvent], None]

The hub's events, ending when the hub disconnects or the block is

AsyncGenerator[AsyncIterator[HubEvent], None]

left.

Raises:

Type Description
RuntimeError

If this connection has no notification router, which would leave the iterator silently empty.