#NEWLINE# def sendQueued( self ) : #NEWLINE# #INDENT# "This should be the only method that will be used to send stats.\n    In order to not hold the event loop and prevent stats from flowing\n    in while we send them out, this will process\n    settings.MAX_DATAPOINTS_PER_MESSAGE stats, send them, and if there\n    are still items in the queue, this will invoke reactor.callLater\n    to schedule another run of sendQueued after a reasonable enough time\n    for the destination to process what it has just received.\n\n    Given a queue size of one million stats, and using a\n    chained_invocation_delay of 0.0001 seconds, you'd get 1,000\n    sendQueued() invocations/second max.  With a\n    settings.MAX_DATAPOINTS_PER_MESSAGE of 100, the rate of stats being\n    sent could theoretically be as high as 100,000 stats/sec, or\n    6,000,000 stats/minute.  This is probably too high for a typical\n    receiver to handle.\n\n    In practice this theoretical max shouldn't be reached because\n    network delays should add an extra delay - probably on the order\n    of 10ms per send, so the queue should drain with an order of\n    minutes, which seems more realistic.\n    " #NEWLINE# queueSize = self . factory . queueSize #NEWLINE# if queueSize . paused : #NEWLINE# #INDENT# instrumentation . max ( self . queuedUntilReady , queueSize ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( not self . factory . hasQueuedDatapoints ( ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( settings . USE_RATIO_RESET is True ) : #NEWLINE# #INDENT# if ( not self . connectionQualityMonitor ( ) ) : #NEWLINE# #INDENT# self . resetConnectionForQualityReasons ( 'Sent: {0}, Received: {1}' . format ( instrumentation . prior_stats . get ( self . sent , 0 ) , instrumentation . prior_stats . get ( 'metricsReceived' , 0 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . _sendDatapoints ( self . factory . takeSomeFromQueue ( ) ) #NEWLINE# if ( self . factory . queueFull . called and ( queueSize < SEND_QUEUE_LOW_WATERMARK ) ) : #NEWLINE# #INDENT# if ( not self . factory . queueHasSpace . called ) : #NEWLINE# #INDENT# self . factory . queueHasSpace . callback ( queueSize ) #NEWLINE# #UNINDENT# #UNINDENT# if self . factory . hasQueuedDatapoints ( ) : #NEWLINE# #INDENT# self . factory . scheduleSend ( )