Skip to content

Commit

Permalink
Catching the context
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: rht <[email protected]>
  • Loading branch information
rht committed Nov 22, 2015
1 parent fe40df8 commit 8d1ea86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/ipfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ func callCommand(ctx context.Context, req cmds.Request, root *cmds.Command, cmd
}
}

go func() {
select {
case <-ctx.Done():
fmt.Fprintf(os.Stderr, "ffff")
}
}()

if client != nil {
log.Debug("Executing command via API")
res, err = client.Send(req)
Expand Down
10 changes: 10 additions & 0 deletions core/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ may also specify the level of compression by specifying '-l=<1-9>'.
return err
},
Run: func(req cmds.Request, res cmds.Response) {
fmt.Fprintf(res.Stderr(), "!!!")

cmplvl, err := getCompressOptions(req)
if err != nil {
res.SetError(err, cmds.ErrClient)
Expand All @@ -63,6 +65,14 @@ may also specify the level of compression by specifying '-l=<1-9>'.
}
p := path.Path(req.Arguments()[0])
ctx := req.Context()

go func() {
select {
case <-ctx.Done():
fmt.Fprintf(res.Stderr(), "here!%s", ctx.Err())
}
}()

dn, err := core.Resolve(ctx, node, p)
if err != nil {
res.SetError(err, cmds.ErrNormal)
Expand Down

0 comments on commit 8d1ea86

Please sign in to comment.