Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"fix go client get params channel return bug" #2702

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions go/pserver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,20 @@ func (c *Client) SendGrads(grads []Gradient) error {
}

recv := 0
var errs []error
for err := range errCh {
if err != nil {
return err
errs = append(errs, err)
}

recv++
if recv == len(grads) {
break
}
}
if len(errs) != 0 {
return errs[0]
}
return nil
}

Expand Down Expand Up @@ -182,18 +186,23 @@ func (c *Client) GetParams(names []string) ([]Parameter, error) {
}

var rs results
var errs []error
recv := 0
for r := range rCh {
if r.err != nil {
return nil, r.err
errs = append(errs, r.err)
} else {
rs = append(rs, r)
}
rs = append(rs, r)

recv++
if recv == len(names) {
break
}
}
if len(errs) != 0 {
return nil, errs[0]
}
sort.Sort(rs)

ps := make([]Parameter, len(rs))
Expand All @@ -214,16 +223,20 @@ func (c *Client) Save(path string) error {
}

recv := 0
var errs []error
for err := range errCh {
if err != nil {
return err
errs = append(errs, err)
}

recv++
if recv == len(c.pservers) {
break
}
}
if len(errs) != 0 {
return errs[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we log all the errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought they are the same errors because there is only one source of error.

}

// TODO(helin): there will be many files under path, need to
// merge them into a single file.
Expand Down