ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
517 stars 525 forks source link

Only initialize embedded python interpreter once. #491

Closed mikepurvis closed 4 years ago

mikepurvis commented 4 years ago

Should address #450.

@tongtybj, @TobinHall, @stertingen Can you give this a try and confirm that it addresses the issue you were seeing with PyImport_ImportModule?

mikepurvis commented 4 years ago

Would be interesting to see if the ast module can be repeatedly imported— I suspect so, and that would side-step a lot of this, if we only parsed the message file rather than actually importing it. Main drag would be having to have more of the actual logic implemented in Python (using importlib to located the correct source file, ast to parse it, and then navigating the parsed tree to extract the two strings we care about). So we'd either have to have that be a script located somewhere that the embedded interpreter could invoke, or have it be inlined in the cpp file as a string. Neither seems ideal.

Anyway, a project for another day if someone wants to look. :)