#NEWLINE# def populate( self , max_wait = 2.0 , wait_for_complete = True , query_cl = None ) : #NEWLINE# #INDENT# '\n        Retrieves the actual tracing details from Cassandra and populates the\n        attributes of this instance.  Because tracing details are stored\n        asynchronously by Cassandra, this may need to retry the session\n        detail fetch.  If the trace is still not available after `max_wait`\n        seconds, :exc:`.TraceUnavailable` will be raised; if `max_wait` is\n        :const:`None`, this will retry forever.\n\n        `wait_for_complete=False` bypasses the wait for duration to be populated.\n        This can be used to query events from partial sessions.\n\n        `query_cl` specifies a consistency level to use for polling the trace tables,\n        if it should be different than the session default.\n        ' #NEWLINE# attempt = 0 #NEWLINE# start = time . time ( ) #NEWLINE# while True : #NEWLINE# #INDENT# time_spent = ( time . time ( ) - start ) #NEWLINE# if ( ( max_wait is not None ) and ( time_spent >= max_wait ) ) : #NEWLINE# #INDENT# raise TraceUnavailable ( ( 'Trace information was not available within %f seconds. Consider raising Session.max_trace_wait.' % ( max_wait , ) ) ) #NEWLINE# #UNINDENT# log . debug ( 'Attempting to fetch trace info for trace ID: %s' , self . trace_id ) #NEWLINE# session_results = self . _execute ( SimpleStatement ( self . _SELECT_SESSIONS_FORMAT , consistency_level = query_cl ) , ( self . trace_id , ) , time_spent , max_wait ) #NEWLINE# is_complete = ( session_results and ( session_results [ 0 ] . duration is not None ) ) #NEWLINE# if ( ( not session_results ) or ( wait_for_complete and ( not is_complete ) ) ) : #NEWLINE# #INDENT# time . sleep ( ( self . _BASE_RETRY_SLEEP * ( 2 ** attempt ) ) ) #NEWLINE# attempt += 1 #NEWLINE# continue #NEWLINE# #UNINDENT# if is_complete : #NEWLINE# #INDENT# log . debug ( 'Fetched trace info for trace ID: %s' , self . trace_id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . debug ( 'Fetching parital trace info for trace ID: %s' , self . trace_id ) #NEWLINE# #UNINDENT# session_row = session_results [ 0 ] #NEWLINE# self . request_type = session_row . request #NEWLINE# self . duration = ( timedelta ( microseconds = session_row . duration ) if is_complete else None ) #NEWLINE# self . started_at = session_row . started_at #NEWLINE# self . coordinator = session_row . coordinator #NEWLINE# self . parameters = session_row . parameters #NEWLINE# self . client = getattr ( session_row , 'client' , None ) #NEWLINE# log . debug ( 'Attempting to fetch trace events for trace ID: %s' , self . trace_id ) #NEWLINE# time_spent = ( time . time ( ) - start ) #NEWLINE# event_results = self . _execute ( SimpleStatement ( self . _SELECT_EVENTS_FORMAT , consistency_level = event_results ) , ( self . trace_id , ) , time_spent , max_wait ) #NEWLINE# log . debug ( 'Fetched trace events for trace ID: %s' , self . trace_id ) #NEWLINE# self . events = tuple ( ( TraceEvent ( r . activity , r . event_id , r . source , r . source_elapsed , r . thread ) for r in event_results ) ) #NEWLINE# break