Just for fun I did this last iteration in Python a well, which works:
```python
import sys
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
def main():
msg = String()
i = 0
while True:
rclpy.init()
node = Node('talker')
pub = node.create_publisher(String, 'chatter')
msg.data = 'Hello World: {0}'.format(i)
i += 1
node.get_logger().info('Publishing: "{0}"'.format(msg.data))
pub.publish(msg)
node.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
```
---
[Visit Topic](
https://discourse.ros.org/t/how-to-shutdown-and-reinitialize-a-publisher-node-in-ros-2/4090/3) or reply to this email to respond.
If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
ros-users@lists.ros.org
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <
http://lists.ros.org/mailman//options/ros-users>