update examples

This commit is contained in:
Xing Xing 2014-03-03 15:23:46 +08:00
parent 76c76995d5
commit 09542d7176

View File

@ -7,6 +7,7 @@ import (
"os" "os"
"strings" "strings"
"time" "time"
"net"
) )
func ToUpper(job worker.Job) ([]byte, error) { func ToUpper(job worker.Job) ([]byte, error) {
@ -39,13 +40,15 @@ func main() {
defer w.Close() defer w.Close()
w.ErrorHandler = func(e error) { w.ErrorHandler = func(e error) {
log.Println(e) log.Println(e)
if e == worker.ErrLostConn { if opErr, ok := e.(*net.OpError); ok {
proc, err := os.FindProcess(os.Getpid()) if ! opErr.Temporary() {
if err != nil { proc, err := os.FindProcess(os.Getpid())
log.Println(err) if err != nil {
} log.Println(err)
if err := proc.Signal(os.Interrupt); err != nil { }
log.Println(err) if err := proc.Signal(os.Interrupt); err != nil {
log.Println(err)
}
} }
} }
} }