Package rospy :: Package impl :: Module statistics :: Class ConnectionStatisticsLogger

Class ConnectionStatisticsLogger

source code

Class that monitors lots of stuff for each connection.

is created whenever a subscriber is created. is destroyed whenever its parent subscriber is destroyed. its lifecycle is therefore bound to its parent subscriber.

Instance Methods
 
__init__(self, topic, subscriber, publisher)
Constructor.
source code
 
sendStatistics(self, subscriber_statistics_logger)
Send out statistics.
source code
 
callback(self, subscriber_statistics_logger, msg, stat_bytes)
This method is called for every message, that is received on this subscriber.
source code
 
shutdown(self) source code
Method Details

__init__(self, topic, subscriber, publisher)
(Constructor)

source code 

Constructor.

Parameters:
  • topic - Name of the topic
  • subscriber - Name of the subscriber
  • publisher - Name of the publisher

    These three should uniquely identify the connection.

sendStatistics(self, subscriber_statistics_logger)

source code 

Send out statistics. Aggregate collected stats information.

Currently done blocking. Might be moved to own thread later. But at the moment any computation done here should be rather quick.

callback(self, subscriber_statistics_logger, msg, stat_bytes)

source code 

This method is called for every message, that is received on this subscriber.

this callback will keep some statistics and publish the results periodically on a topic. the publishing should probably be done asynchronically in another thread.

Parameters:
  • msg - The message, that has been received. The message has usually been already deserialized. However this is not always the case. (AnyMsg)
  • stat_bytes - A counter, how many bytes have been moved across this connection since it exists.

    Any computing-heavy stuff should be done somewhere else, as this callback has to return before the message is delivered to the user.