unf.Broker

class unf.Broker

Intermediate object between the Usd Stage and any clients that needs asynchronous handling and upstream filtering of notices.

static Create(stage)

Create a broker from a Usd Stage.

If a broker has already been created from this stage, it will be returned. Otherwise, a new one will be created and returned.

Example:

stage = Usd.Stage.CreateInMemory()
broker = Broker(stage)
Parameters:

stage – Instance of Usd Stage.

Returns:

Instance of unf.Broker.

GetStage()

Return Usd Stage associated with the broker.

Returns:

Instance of Usd Stage.

IsInTransaction()

Indicate whether a notice transaction has been started.

Returns:

Boolean value.

BeginTransaction(predicate=CapturePredicate.Default())

Start a notice transaction.

Notices derived from unf.Notice.StageNotice will be held during the transaction and emitted at the end.

By default, all unf.Notice.StageNotice notices will be captured during the entire scope of the transaction. A function predicate or a unf.CapturePredicate instance can be passed to influence which notices are captured.

Notices that are not captured will not be emitted.

Example:

# Block all notices emitted within the transaction.
broker.BeginTransaction(predicate=CapturePredicate.BlockAll())

# Block all notices from type 'Foo' emitted during transaction.
broker.BeginTransaction(predicate=lambda n: not isinstance(n, Foo))

Warning

Each transaction started must be closed with EndTransaction(). It is preferrable to use unf.NoticeTransaction over this API to safely manage transactions.

Parameters:

predicate – Instance of unf.CapturePredicate or function taking a unf.Notice.StageNotice instance and returning a boolean value. By default, the unf.apturePredicate.Default() predicate is used.

EndTransaction()

Stop a notice transaction.

This will trigger the emission of all captured unf.Notice.StageNotice notices. Each notice type will be consolidated before emission if applicable.

Warning

It is preferrable to use unf.NoticeTransaction over this API to safely manage transactions.