How to combine Panda3D and Openai Gym?

I want to develop a 3D environment for Renforcement learning(RL) based on Gym. Panda3D is great for developing 3D games.
After a few days of study, I developed a small game. However, when I tried to integrate with Gym, I found some problems.
Panda3d rendering graphics need call the function app.run(), but after that, the game’s control handle is not available.
How can I manually render each frame graphics without calling app.run()?
Anyone konw how to do?