|
|
|
@@ -12,9 +12,11 @@ import ( |
|
|
|
) |
|
|
|
|
|
|
|
var noteBookOKMap = make(map[int64]int, 20) |
|
|
|
var noteBookFailMap = make(map[int64]int, 20) |
|
|
|
|
|
|
|
//if a task notebook url can get two times, the notebook can browser. |
|
|
|
//if a task notebook url can get successfulCount times, the notebook can browser. |
|
|
|
const successfulCount = 3 |
|
|
|
const maxSuccessfulCount=12 |
|
|
|
|
|
|
|
func SyncCloudBrainOneStatus(task *models.Cloudbrain) (*models.Cloudbrain, error) { |
|
|
|
jobResult, err := cloudbrain.GetJob(task.JobID) |
|
|
|
@@ -68,15 +70,22 @@ func isNoteBookReady(task *models.Cloudbrain) bool { |
|
|
|
return false |
|
|
|
} |
|
|
|
if res.StatusCode == http.StatusOK { |
|
|
|
|
|
|
|
count := noteBookOKMap[task.ID] |
|
|
|
if count < successfulCount-1 { |
|
|
|
if count < successfulCount-1 || (noteBookFailMap[task.ID]==0 || count < maxSuccessfulCount-1){ |
|
|
|
noteBookOKMap[task.ID] = count + 1 |
|
|
|
return false |
|
|
|
} else { |
|
|
|
delete(noteBookOKMap, task.ID) |
|
|
|
delete(noteBookFailMap, task.ID) |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
noteBookFailMap[task.ID]+=1 |
|
|
|
if noteBookOKMap[task.ID]>0{ |
|
|
|
noteBookOKMap[task.ID]=0 |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
|
|
|
|
|