mirror of
https://github.com/danog/gojekyll.git
synced 2024-12-02 15:57:49 +01:00
Fix running out of file descriptors
This commit is contained in:
parent
e22984cdc6
commit
b51cd1b295
@ -6,7 +6,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/osteele/gojekyll/pages"
|
"github.com/osteele/gojekyll/pages"
|
||||||
@ -17,12 +16,19 @@ import (
|
|||||||
// WriteFiles writes output files.
|
// WriteFiles writes output files.
|
||||||
// It attends to options.dry_run.
|
// It attends to options.dry_run.
|
||||||
func (s *Site) WriteFiles() (count int, err error) {
|
func (s *Site) WriteFiles() (count int, err error) {
|
||||||
errs := make(chan error, runtime.NumCPU())
|
errs := make(chan error)
|
||||||
for _, p := range s.OutputDocs() {
|
// without this, large sites run out of file descriptors
|
||||||
|
sem := make(chan bool, 20)
|
||||||
|
for i, n := 0, cap(sem); i < n; i++ {
|
||||||
|
sem <- true
|
||||||
|
}
|
||||||
|
for _, d := range s.OutputDocs() {
|
||||||
count++
|
count++
|
||||||
go func(d pages.Document) {
|
go func(d pages.Document) {
|
||||||
|
<-sem
|
||||||
errs <- s.WriteDoc(d)
|
errs <- s.WriteDoc(d)
|
||||||
}(p)
|
sem <- true
|
||||||
|
}(d)
|
||||||
}
|
}
|
||||||
var errList []error
|
var errList []error
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
|
Loading…
Reference in New Issue
Block a user