Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: client/cmd/isolate/archive.go

Issue 2936713003: Sever isolate cmd dependency on Canceler. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/cmd/isolate/batch_archive.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/isolate/archive.go
diff --git a/client/cmd/isolate/archive.go b/client/cmd/isolate/archive.go
index 5260bc5b1ef2cdab75b41af113dabec7c390c9fc..1c7290c5cdcc9a96954e4872be3e59fb98844326 100644
--- a/client/cmd/isolate/archive.go
+++ b/client/cmd/isolate/archive.go
@@ -9,6 +9,7 @@ import (
"fmt"
"log"
"os"
+ "os/signal"
"path/filepath"
"time"
@@ -16,7 +17,6 @@ import (
"github.com/maruel/subcommands"
"github.com/luci/luci-go/client/archiver"
- "github.com/luci/luci-go/client/internal/common"
"github.com/luci/luci-go/client/isolate"
"github.com/luci/luci-go/common/auth"
"github.com/luci/luci-go/common/data/text/units"
@@ -75,7 +75,7 @@ func (c *archiveRun) main(a subcommands.Application, args []string) error {
}
ctx := c.defaultFlags.MakeLoggingContext(os.Stderr)
arch := archiver.New(ctx, isolatedclient.New(nil, client, c.isolatedFlags.ServerURL, c.isolatedFlags.Namespace, nil, nil), out)
- common.CancelOnCtrlC(arch)
+ CancelOnCtrlC(arch)
item := isolate.Archive(arch, &c.ArchiveOptions)
item.WaitForHashed()
if err = item.Error(); err != nil {
@@ -130,3 +130,19 @@ func (c *archiveRun) Run(a subcommands.Application, args []string, _ subcommands
}
return 0
}
+
+// CancelOnCtrlC is a temporary copy of the CancelOnCtrlC in internal/common/concurrent.go
+// This is needed until the old archive and batcharchive code (which uses Cancelers) is removed.
+// It operates on a concrete Archiver to avoid the dependency on Canceler.
+func CancelOnCtrlC(arch *archiver.Archiver) {
+ interrupted := make(chan os.Signal, 1)
+ signal.Notify(interrupted, os.Interrupt)
+ go func() {
+ defer signal.Stop(interrupted)
+ select {
+ case <-interrupted:
+ arch.Cancel(errors.New("Ctrl-C"))
+ case <-arch.Channel():
+ }
+ }()
+}
« no previous file with comments | « no previous file | client/cmd/isolate/batch_archive.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698