nv_dfm_core.session.DirectDispatcher#

class nv_dfm_core.session.DirectDispatcher[source]#

Default dispatcher: calls callbacks immediately from the background thread.

This preserves the current behavior where callbacks are invoked directly in the thread that receives the tokens. This is the default dispatcher used by Session when no other dispatcher is specified.

Note: DirectDispatcher only supports synchronous callbacks. If you need to use async callbacks, use AsyncioDispatcher instead.

Example

# Explicit usage (same as default behavior) session = Session(

federation_name=”my_fed”, homesite=”site1”, callback_dispatcher=DirectDispatcher()

)

create_runner(default_callback=None, place_callbacks=None)[source]#

Create a DirectRunner for synchronous callback execution.

Parameters:
  • default_callback (DfmDataCallback | None) – Fallback callback for tokens without a place-specific callback.

  • place_callbacks (dict[str, DfmDataCallback] | None) – Dictionary mapping place names to callbacks.

Returns:

A _DirectRunner instance that calls callbacks immediately.

Raises:

ValueError – If any callback is asynchronous (use AsyncioDispatcher instead).

Return type:

CallbackRunner