Code Monkey home page Code Monkey logo

ctx's People

Contributors

lthibault avatar orisano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ctx's Issues

sigctx: SIGINT won't exit

@lthibault Opening a new issue per discussion in #4. The import side-effect is now resolved (awesome!) but I'm still seeing the signal.Stop() issue. Here is my test program again:

package main

import (
	"log"
	"os"
	"time"

	"github.com/SentimensRG/ctx/sigctx" // ctrl-c will not work if you pass `server` as an arg
	//"github.com/mhupman/ctx/sigctx" // ctrl-c will work in either case
)

func main() {
	if len(os.Args) > 1 && os.Args[1] == "server" {
		go startServer()
	}

	log.Println("starting some kind of long running op - ctrl-c to quit me!")
	for {
		time.Sleep(time.Second)
	}
}

func startServer() {
	log.Println("starting server")
	<-sigctx.New().Done()
	log.Println("server done")
}

No matter how many times I ctrl-c, it hangs. If I add a signal.Stop(sigCh) on sigctx/sigctx.go#38 it seems to fix the problem and SIGINTs will cause a program exit.

Unit tests

$ go test -cover -race ./...                                                              (328ms) 
ok  	github.com/SentimensRG/ctx	1.035s	coverage: 73.0% of statements
ok  	github.com/SentimensRG/ctx/mergectx	1.711s	coverage: 54.0% of statements
ok  	github.com/SentimensRG/ctx/refctx	1.032s	coverage: 75.0% of statements
?   	github.com/SentimensRG/ctx/sigctx	[no test files]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.