[rospy] Implement rospy.logXXX_throttle#812
[rospy] Implement rospy.logXXX_throttle#812wkentaro wants to merge 4 commits intoros:kinetic-develfrom
Conversation
clients/rospy/src/rospy/core.py
Outdated
| """ | ||
| now = rospy.Time.now() | ||
|
|
||
| last_logging_time = self.last_logging_time_table.get(id) |
There was a problem hiding this comment.
Is the id sufficient for this? From the following code I would expect both messages to be printed every three seconds (which I would assume is not the case currently?):
while True:
loginfo_throttle(3, 'foo') or loginfo_throttle(3, 'foo')
There was a problem hiding this comment.
Maybe I need to get more detailed position where the function is called.
Currently, the inspect.stack()[1][1:] returns only line where the function is called:
Because there is the case where the logging functions, period and msg are all same.
% cat spam.py
import inspect
def loginfo_throttle():
print(inspect.stack()[1])
def main():
loginfo_throttle(); loginfo_throttle()
if __name__ == '__main__':
main()
% python spam.py
(<frame object at 0x7f3d6b2ed3a0>, 'spam.py', 9, 'main', [' loginfo_throttle(); loginfo_throttle()\n'], 0)
(<frame object at 0x7f3d6b2ed3a0>, 'spam.py', 9, 'main', [' loginfo_throttle(); loginfo_throttle()\n'], 0)
There was a problem hiding this comment.
But currently I don't know how to get the called location with information about lines and columns.
inspect.stack()[1][1:] only returns the line and line number.
There was a problem hiding this comment.
Posted on stackoverflow to asking about this: http://stackoverflow.com/questions/37606094/is-there-way-to-get-function-called-column-location-not-only-file-and-line-infor
There was a problem hiding this comment.
I found the way to get column number where the function is called.
http://stackoverflow.com/questions/37606094/is-there-way-to-get-function-called-column-location-not-only-file-and-line-infor/37614347#37614347
|
Just a data point: I've looked into this some time in the past as well, and could not arrive at a solution that was both portable ( See rospy: throttling logmessage rate? for the question on ROS Answers and (my own) answer. I'm not really a Python expert, so it is very well possible that I missed something or am just ignorant. It would be really nice if this could be fixed though, so +1 for working on it @wkentaro. |
|
@gavanderhoorn In what cases, the |
|
I didn't say it doesn't work, I said it doesn't necessarily return the same information, and in the same format. I don't have my full notes anymore (it was 3 years ago), but iirc, some Python interpreters either don't return the required info, or don't return everything, or in a slightly different format. That makes it difficult to implement something that always works. Now how much of a problem that is, I don't know. If we are happy with it working on the regular / official Python interpreters, fine by me. I just didn't want to implement something with if/else trees and / or special cases. |
|
@dirk-thomas I have done the implementation. Could you please review again? |
|
As long as the The Thanks for iterating on this. I have squashed and cherry-picked this in 5daef56. Can you please update the wiki page to add some documentation about these new functions mentioning that they are new in Kinetic and comment with a link to the diff here. |
|
Thanks for the review. BTW, Is that possible to add this feature also to Indigo and Jade? |
Periodicall logging feature for python client.