提交 4970484d 编写于 作者: H Helin Wang

improve comment, fix build error

上级 7b9080ef
...@@ -34,6 +34,8 @@ func (c *Client) getRecords() { ...@@ -34,6 +34,8 @@ func (c *Client) getRecords() {
for { for {
t, err := c.getTask() t, err := c.getTask()
if err != nil { if err != nil {
// TODO(helin): wait before move on with next
// getTask call.
log.Println(err) log.Println(err)
continue continue
} }
...@@ -125,7 +127,7 @@ func (c *Client) taskFinished(taskID int) error { ...@@ -125,7 +127,7 @@ func (c *Client) taskFinished(taskID int) error {
// NextRecord returns next record in the dataset. // NextRecord returns next record in the dataset.
// //
// NextRecord will block until next record is available. It is // NextRecord will block until the next record is available. It is
// thread-safe. // thread-safe.
func (c *Client) NextRecord() []byte { func (c *Client) NextRecord() []byte {
return <-c.ch return <-c.ch
......
...@@ -75,6 +75,7 @@ func TestGetFinishTask(t *testing.T) { ...@@ -75,6 +75,7 @@ func TestGetFinishTask(t *testing.T) {
} }
f.Close() f.Close()
// Manually intialize client to avoid calling c.getRecords()
c := &Client{} c := &Client{}
c.conn = connection.New() c.conn = connection.New()
go c.monitorMaster(TestAddresser(fmt.Sprintf(":%d", p))) go c.monitorMaster(TestAddresser(fmt.Sprintf(":%d", p)))
...@@ -85,19 +86,19 @@ func TestGetFinishTask(t *testing.T) { ...@@ -85,19 +86,19 @@ func TestGetFinishTask(t *testing.T) {
for idx := 0; idx < totalTask; idx++ { for idx := 0; idx < totalTask; idx++ {
task, err := c.getTask() task, err := c.getTask()
if err != nil { if err != nil {
t.Fatal(err, " pass:", i) t.Fatalf("Error: %v, pass: %d\n", err, i)
} }
tasks = append(tasks, task) tasks = append(tasks, task)
} }
_, err = c.getTask() _, err = c.getTask()
if err == nil { if err == nil {
t.Fatal("Should get error. Pass:", i) t.Fatalf("Should get error, pass: %d\n", i)
} }
err = c.taskFinished(tasks[0].ID) err = c.taskFinished(tasks[0].ID)
if err != nil { if err != nil {
t.Fatal(err, "pass:", i) t.Fatalf("Error: %v, pass: %d\n", err, i)
} }
tasks = tasks[1:] tasks = tasks[1:]
task, err := c.getTask() task, err := c.getTask()
...@@ -109,7 +110,7 @@ func TestGetFinishTask(t *testing.T) { ...@@ -109,7 +110,7 @@ func TestGetFinishTask(t *testing.T) {
for _, task := range tasks { for _, task := range tasks {
err = c.taskFinished(task.ID) err = c.taskFinished(task.ID)
if err != nil { if err != nil {
t.Fatal(err, " pass:", i) t.Fatalf("Error: %v, pass: %d\n", err, i)
} }
} }
} }
......
...@@ -207,12 +207,12 @@ func (s *Service) checkTimeoutFunc(taskID int, epoch int) func() { ...@@ -207,12 +207,12 @@ func (s *Service) checkTimeoutFunc(taskID int, epoch int) func() {
t.NumTimeout++ t.NumTimeout++
if t.NumTimeout > s.timeoutMax { if t.NumTimeout > s.timeoutMax {
log.Warningf("Task %v failed %d times, discard.\n", t.Task, t.NumTimeout) log.Warningf("Task %v timed out %d times, discard.\n", t.Task, t.NumTimeout)
s.taskQueues.Failed = append(s.taskQueues.Failed, t.Task) s.taskQueues.Failed = append(s.taskQueues.Failed, t.Task)
return return
} }
log.Warningf("Task %v failed %d times, retry.\n", t.Task, t.NumTimeout) log.Warningf("Task %v timed out %d times, retry.\n", t.Task, t.NumTimeout)
s.taskQueues.Todo = append(s.taskQueues.Todo, t) s.taskQueues.Todo = append(s.taskQueues.Todo, t)
} }
} }
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "libpaddle_pserver_cclient.h" #include "libpaddle_pserver_cclient.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册