Open felixdivo opened 1 year ago
This is a good idea, thanks. We probably aren't going to work on this, but we would definitely review pull requests that implemented it.
Okay nice. Is wrapping around context.init()
/context.try_shutdown()
even the right thing to do? Then maybe I can have a look. 😄
Yep, I think it maps the ROS concept cleanly into a more pythonic pattern. Happy to take a look if you open a PR.
There is also #1118, for rclpy.executor.Executor
Feature request
Feature description
rclpy.context.Context
would be useful to have as a context manager. This would allow for:Instead of
The first approach is shorter and (for some) conceptually easier. In both cases
context
can be referenced afterwards although it is invalid. However, in the first case it is much more clear that any sane use is within thewith context: ...
construct. And, one cannot forget to close it in the end. It is arguably more Pythonic.Implementation considerations
One could use
shutdown
ortry_shutdown
at the end of the context block. The latter makes more sense, since it allows for more complex scenarios where the context is already in some of the cases.