Live.block_for_close

Block 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.block_for_close(
    timeout: float | None = None,
) -> None
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()

# Block for the session to close
client.block_for_close()