unf.NoticeTransaction

class unf.NoticeTransaction

Context manager object which consolidates and filter notices derived from unf.Notice.StageNotice within a specific scope.

A transaction can be started with a Broker instance, or with a Usd Stage instance. If the later option is chosen, a Broker instance will be automatically created if none is associated with the incoming stage.

# Create a transaction from a broker.
with NoticeTransaction(broker) as transaction:
    ...

# Create a transaction from a stage.
with NoticeTransaction(stage) as transaction:
    broker = transaction.GetBroker()

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.

# Block all notices emitted within the transaction.
with NoticeTransaction(
    broker, predicate=CapturePredicate.BlockAll()
) as transaction:
    ...

# Block all notices from type 'Foo' emitted during transaction.
with NoticeTransaction(
    broker, predicate=lambda n: not isinstance(n, Foo)
) as transaction:
    ...
__init__(target, predicate=CapturePredicate.Default())
Parameters:
Returns:

Instance of unf.NoticeTransaction.

GetBroker()

Return associated unf.Broker instance.

Returns:

Instance of unf.Broker.