Simulator handles more errors.

This commit is contained in:
Nick Winter 2014-03-26 12:12:43 -07:00
parent ac222c27e8
commit 515b8723a3

View file

@ -44,10 +44,18 @@ module.exports = class Simulator extends CocoClass
return @handleNoGamesResponse() if jqXHR.status is 204
@trigger 'statusUpdate', 'Setting up simulation!'
@task = new SimulationTask(taskData)
try
levelID = @task.getLevelName()
catch err
console.error err
@trigger 'statusUpdate', "Error simulating game: #{err}. Trying another game in #{@retryDelayInSeconds} seconds."
@simulateAnotherTaskAfterDelay()
return
@supermodel ?= new SuperModel()
@god = new God maxWorkerPoolSize: 1, maxAngels: 1 # Start loading worker.
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: @task.getLevelName(), sessionID: @task.getFirstSessionID(), headless: true
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: levelID, sessionID: @task.getFirstSessionID(), headless: true
@listenToOnce(@levelLoader, 'loaded-all', @simulateGame)
simulateGame: ->
@ -86,8 +94,8 @@ module.exports = class Simulator extends CocoClass
onInfiniteLoop: ->
console.warn "Skipping infinitely looping game."
@trigger 'statusUpdate', 'Infinite loop detected; grabbing a new game.'
_.delay @cleanupAndSimulateAnotherTask, 5000
@trigger 'statusUpdate', "Infinite loop detected; grabbing a new game in #{@retryDelayInSeconds} seconds."
_.delay @cleanupAndSimulateAnotherTask, @retryDelayInMilliseconds
processResults: (simulationResults) ->
taskResults = @formTaskResultsObject simulationResults