mirror of
https://github.com/terorie/od-database-crawler.git
synced 2025-12-13 15:19:03 +00:00
Getting tasks
This commit is contained in:
10
scheduler.go
10
scheduler.go
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
var activeTasks int32
|
||||
@@ -40,6 +41,15 @@ func Schedule(c context.Context, remotes <-chan *OD) {
|
||||
|
||||
// Upload result when ready
|
||||
go remote.Watch(results)
|
||||
|
||||
for atomic.LoadInt32(&activeTasks) > config.Tasks {
|
||||
select {
|
||||
case <-c.Done():
|
||||
return
|
||||
case <-time.After(time.Second):
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user