Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1537 from IRCody/gh1521
Browse files Browse the repository at this point in the history
Fixes #1521: Snaptel hang on task watch
  • Loading branch information
IRCody authored Mar 1, 2017
2 parents 71fcb21 + d364e37 commit 17f0e1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mgmt/rest/client/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func (c *Client) CreateTask(s *Schedule, wf *wmap.WorkflowMap, name string, dead
// interactive with Event and Done channels. An HTTP GET request retrieves tasks.
// StreamedTaskEvent returns if it succeeds. Otherwise, an error is returned.
func (c *Client) WatchTask(id string) *WatchTasksResult {
// during watch we don't want to have a timeout
// Store the old timeout so we can restore when we are through
oldTimeout := c.http.Timeout
c.http.Timeout = time.Duration(0)

r := &WatchTasksResult{
EventChan: make(chan *rbody.StreamedTaskEvent),
DoneChan: make(chan struct{}),
Expand Down Expand Up @@ -131,6 +136,7 @@ func (c *Client) WatchTask(id string) *WatchTasksResult {
// Start watching
go func() {
reader := bufio.NewReader(resp.Body)
defer func() { c.http.Timeout = oldTimeout }()
for {
select {
case <-r.DoneChan:
Expand Down

0 comments on commit 17f0e1c

Please sign in to comment.