title: What is an alternative method for rospy.spin()?
body: <p>I have a custom ros node, that subscribes data from robot-joints. in order to access the joint data, I have a None variable to which the joint positions are being assigned during function callback. Now, the problem is , i can only access that variable when the subscriber is running, once its stopped, the variable is being reset to None. If the ros node keeps running, my program can not skip to the next line unless this loop is stopped. So i am either struck with this loop where I get all this data printed through loginfo or if i remove the line rospy.spin(), in the next lines where I am using that position stored data, its returning None as the node is stopped. Can anyone please suggest me a work around for this ?</p>
  
  <pre><code>   def callback(data):
         Position = data.position
  </code></pre>
  
  <p>I am using this callback in the subscriber
  I want to access the position values of the robot when I call position, as I have assigned data.position to position. but its returning <code>None</code>, I believe its because, since position is <code>None</code> type, it only gets the data.position values assigned to it as long as the node is spinning or running, once its stopped it might be getting reset to <code>None</code>. but if i let it keep spinning using <code>rospy.spin()</code>, my program does not move forward to the next step as it gets stuck in the infinite loop of <code>rospy.spin</code></p>