hust-diangroup / ns3-ai

Enable the interaction between ns-3 and popular frameworks using Python, which mean you can train and test your AI algorithms in ns-3 without changing any frameworks you are using now!
GNU General Public License v2.0
220 stars 80 forks source link

Race condition for `ScheduleDestroy` events when `reset`ing the environment #114

Open Kakadus opened 5 months ago

Kakadus commented 5 months ago

Resetting a running environment sends a close_command to the simulation. Then, the ns3 simulator is destroyed, and all ScheduleDestroy events should be handled: https://github.com/hust-diangroup/ns3-ai/blob/7dc5b1b8d574eb587b088fa959a230c2b4e1aa75/model/gym-interface/cpp/ns3-ai-gym-interface.cc#L210-L211

In parallel, the experiment is runned again, which kills the old environment and interrupts the ScheduleDestroy events. https://github.com/hust-diangroup/ns3-ai/blob/7dc5b1b8d574eb587b088fa959a230c2b4e1aa75/python_utils/ns3ai_utils.py#L147-L148

Instead, I expected that all events scheduled with ScheduleDestroy are executed when I reset the environment. It would be a nice feature to execute these events, when I close the environment.