01234567890123456789012345678901234567890123456789012345678901234567890123456789
73107311731273137314731573167317731873197320732173227323732473257326732773287329 733073317332733373347335733673377338733973407341734273437344734573467347734873497350 | <----SKIPPED LINES----> else: remote, servo = RefreshArduinos( remote, servo, to_remote_q, to_servo_q, to_main_q, shutdown, flights, json_desc_dict, configuration, screen_history) message_queue, next_message_time = ProcessArduinoCommmands( to_main_q, flights, configuration, message_queue, next_message_time) personal_message = PersonalMessage( configuration, message_queue, personal_message) # MEMORY MANAGEMENT # now that we've saved the flight, we have no more need to keep the # memory-hogging persistent_path key of that flight in live memory if 'persistent_path' in flights[-1]: del flights[-1]['persistent_path'] # it turns out we only need the last screen in the screen history, not # the entire history, so we can purge all the rest from active memory # to eliminate a slow-growing memory hog screen_history = [screen_history[-1]] # we also do not need more than MAX_INSIGHT_HORIZON_DAYS of history # of the flights, so we can purge flights older than that as the flights # list slowly grows over time. we can search the entire list every time # but that's unnecessary; instead we can just pop off the 0-th element # each time through the list if it's more than 1 + max days in the past. # Why + 1? Because the histogram generation expects that many *full* days # of history, so to make sure we don't have a partial day if we were to # generate the monthly histograms mid-day, we will keep an extra day. if time.time() - flights[0]['now'] > SECONDS_IN_DAY * ( MAX_INSIGHT_HORIZON_DAYS + 1): flights.pop(0) if SIMULATION: if now: simulated_hour = EpochDisplayTime(now, '%Y-%m-%d %H:00%z') if simulated_hour != prev_simulated_hour: print(simulated_hour) prev_simulated_hour = simulated_hour histogram = ReadAndParseSettings(HISTOGRAM_CONFIG_FILE) <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351 | <----SKIPPED LINES----> else: remote, servo = RefreshArduinos( remote, servo, to_remote_q, to_servo_q, to_main_q, shutdown, flights, json_desc_dict, configuration, screen_history) message_queue, next_message_time = ProcessArduinoCommmands( to_main_q, flights, configuration, message_queue, next_message_time) personal_message = PersonalMessage( configuration, message_queue, personal_message) # MEMORY MANAGEMENT # now that we've saved the flight, we have no more need to keep the # memory-hogging persistent_path key of that flight in live memory if 'persistent_path' in flights[-1]: del flights[-1]['persistent_path'] # it turns out we only need the last screen in the screen history, not # the entire history, so we can purge all the rest from active memory # to eliminate a slow-growing memory hog if screen_history: screen_history = [screen_history[-1]] # we also do not need more than MAX_INSIGHT_HORIZON_DAYS of history # of the flights, so we can purge flights older than that as the flights # list slowly grows over time. we can search the entire list every time # but that's unnecessary; instead we can just pop off the 0-th element # each time through the list if it's more than 1 + max days in the past. # Why + 1? Because the histogram generation expects that many *full* days # of history, so to make sure we don't have a partial day if we were to # generate the monthly histograms mid-day, we will keep an extra day. if time.time() - flights[0]['now'] > SECONDS_IN_DAY * ( MAX_INSIGHT_HORIZON_DAYS + 1): flights.pop(0) if SIMULATION: if now: simulated_hour = EpochDisplayTime(now, '%Y-%m-%d %H:00%z') if simulated_hour != prev_simulated_hour: print(simulated_hour) prev_simulated_hour = simulated_hour histogram = ReadAndParseSettings(HISTOGRAM_CONFIG_FILE) <----SKIPPED LINES----> |