This repository was archived by the owner on Oct 11, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-15
lines changed
Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -240,28 +240,30 @@ private async Task StopInactiveSimulationsAsync(IList<Simulation> activeSimulati
240240
241241 private async Task SaveSimulationStatisticsAsync ( IList < Simulation > simulations )
242242 {
243- foreach ( var simulation in simulations )
243+ DateTimeOffset now = DateTimeOffset . UtcNow ;
244+ TimeSpan duration = now - this . lastSaveStatisticsTime ;
245+
246+ // Save statistics for simulations at specified interval
247+ if ( duration . Seconds >= SAVE_STATS_INTERVAL_SECS )
244248 {
245- try
249+ foreach ( var simulation in simulations )
246250 {
247- if ( this . simulationManagers . ContainsKey ( simulation . Id ) )
251+ try
248252 {
249- DateTimeOffset now = DateTimeOffset . UtcNow ;
250- TimeSpan duration = now - this . lastSaveStatisticsTime ;
251-
252- // Save simulation statistics at specified interval
253- if ( duration . Seconds >= SAVE_STATS_INTERVAL_SECS )
253+ if ( this . simulationManagers . ContainsKey ( simulation . Id ) )
254254 {
255- await this . simulationManagers [ simulation . Id ] . SaveStatisticsAsync ( ) ;
256-
257- this . lastSaveStatisticsTime = now ;
255+ {
256+ await this . simulationManagers [ simulation . Id ] . SaveStatisticsAsync ( ) ;
257+ }
258258 }
259259 }
260+ catch ( Exception e )
261+ {
262+ this . log . Error ( "Failed to save simulation statistics." , ( ) => new { simulation . Id , e } ) ;
263+ }
260264 }
261- catch ( Exception e )
262- {
263- this . log . Error ( "Failed to save simulation statistics." , ( ) => new { simulation . Id , e } ) ;
264- }
265+
266+ this . lastSaveStatisticsTime = now ;
265267 }
266268 }
267269
You can’t perform that action at this time.
0 commit comments