Creating a custom event on event stream is not working

Hello,

I’d like to add a custom event, and I am running the following script on the Script Editor as described on the Event Streams documentation:

import carb.events
import omni.kit.app
import carb


event_id = carb.events.type_from_string("my.extension.MY_CUSTOM_EVENT")

es = omni.kit.app.get_app().get_message_bus_event_stream()

def on_event(e):
    carb.log_warn("testing")

sub = es.create_subscription_to_pop_by_type(event_id, on_event)

As stated on the documentation, I was expecting to see testing output on the console as a warning on every frame update, but it is not showing anything. I tried start/stop/pause, but it won’t make any difference.

The documentation I am following is here: Event streams — Omniverse Kit 106.1.0 documentation

What could be the problem here? I am also wondering if there is a way to create custom event streams, like the PhysX event stream.

Thanks!

From what you have posted, it looks like you haven’t added “es .push(event_id)” to push the event into the message queue

There is a good code example here
https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/guide/event_streams.html#create-custom-event

Thanks for your response @Richard3D. I am following the example you shared.

If I understand correctly, I think this is needed when you add an event using create_subscription_to_push/create_subscription_to_push_by_type. I am also checking the Carbonite documentation to understand more about the pop/push subscriptions: carb::events::IEventStream — carbonite 167.3 documentation

Push subscriptions work without any issues, but pop ones seem to be failing for some reason, even if I make sure I keep the Subscription object alive.