brutella / hc

hc is a lightweight framework to develop HomeKit accessories in Go.
Apache License 2.0
1.74k stars 189 forks source link

t.Stop() doesn't work #134

Closed guader closed 5 years ago

guader commented 5 years ago

os: macos go version: 1.11.1

With the example provided, even if I call t.Stop() within a timer, process will not exit in 10s as expected. And there is no error reported.

        go func() {
        timer := time.NewTimer(time.Second*10)
        fmt.Print("timer start")
        <- timer.C
        fmt.Print("timer stop")
        t.Stop()
    }()

    //hc.OnTermination(func() {
    //  t.Stop()
    //})

    t.Start()

Then I have to kill it by myself.

timer startINFO 2019/02/14 11:35:11 Accessory address is 192.168.1.163:49533
timer stop^C^C^C^C^Z
[1]+  Stopped                 go run hklightd.go
guader commented 5 years ago

I'm so sorry, it was my mistake. The example code I pulled shows t.Stop() but <-t.Stop().