Skip to content

Commit

Permalink
connect to sync source in a new goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
briansorahan committed Apr 1, 2017
1 parent 9cfb782 commit 404d335
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package launchpad

import (
"context"
"fmt"
"io"
"os"

"github.com/pkg/errors"
"github.com/scgolang/syncosc"
Expand Down Expand Up @@ -153,9 +155,14 @@ func (seq *Sequencer) Main(ctx context.Context) error {
if err != nil {
return err
}
if err := seq.syncConnector(ctx, seq, seq.syncHost); err != nil {
return err
}
// This func could block forever
go func() {
ctx, cancel := context.WithCancel(ctx)
if err := seq.syncConnector(ctx, seq, seq.syncHost); err != nil {
cancel()
fmt.Fprintf(os.Stderr, "connecting to sync source: %s", err.Error())
}
}()
if err := seq.lightCurrentTrack(); err != nil {
return err
}
Expand Down

0 comments on commit 404d335

Please sign in to comment.