How to get kit handler in extension?

I have my custom extension and it commands robot to move joint. However, when i want to wait until the robot reached target position, the ‘time.sleep’ command makes the simulator stuck. How can i get kit handler and update its frame when I wait for the move joint command to finish?

How to update frame in extension within a running isaac sim environment? Because i dont want to restart a simulator using

 kit = OmniKitHelper()

in python script everytime i test. @toni.sm @sdebnath @Sheikh_Dawood

The easiest way to do this is in an extension to use asyncio to await

import asyncio
import omni

async def next_frame():
    await omni.kit.app.get_app().next_update_async()
    print("frame one")
    await omni.kit.app.get_app().next_update_async()
    print("frame two")

asyncio.ensure_future(next_frame())

There are also ways to assign callbacks that get called every frame

self._callback_handle = omni.kit.app.get_app().get_update_event_stream().create_subscription_to_pop(self._update)

@Hammad_M I’ve tried the first method and the simulator is still stuck. I hope i can wait until the joints reach target then start the next execution like taking picture,and the simulator is still running rather than stuck in the waiting process. The process is like sim.step() in mujoco-py.

@Hammad_M Could you give a sample for frame update in asyncio way?