Live.wait_for_close

Wait until the session closes or a timeout is reached. A session will close when the remote gateway disconnects, or after Live.stop or Live.terminate are called. In the event the connection is closed unexpectedly, a BentoError will be raised.

If a timeout is specified, Live.terminate will be called when the timeout is reached.

When this method unblocks, the session is guaranteed to be closed.

Parameters

Parameter
Type
Required
Description
timeout
float
optional
A duration in seconds to wait for the session to close. If None, wait forever.
API method
1
2
3
Live.wait_for_close(
    timeout: float | None = None,
) -> None
Info

This method is a coroutine and must be used with an await expression.

Example usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import databento as db

# Create a live client
client = db.Live(key="$YOUR_API_KEY")

# Subscribe to the trades schema for all ES futures
client.subscribe(
    dataset="GLBX.MDP3",
    schema="trades",
    stype_in="parent",
    symbols="ES.FUT",
)

# Start the session
client.start()

# Wait for the session to end
await client.wait_for_close()