see the "faking time" section here: https://blog.golang.org/playground
not sure if anything has changed since that article On Sat, Aug 31, 2019 at 4:22 PM robert engels <reng...@ix.netcom.com> wrote: > Yes, the code runs fine locally. Reviewing the playground docs, it sees > that at one point time.Sleep() was a no-op and it was changed. I am > thinking that in the course of that change, they forgot to change the > ‘deadlock’ detector. > > On Aug 31, 2019, at 5:17 PM, burak serdar <bser...@computer.org> wrote: > > On Sat, Aug 31, 2019 at 4:13 PM robert engels <reng...@ix.netcom.com> > wrote: > > > The code at https://play.golang.org/p/9ZdPVvwyaYK > > should not deadlock. But it reports: > > > I had the same problem the other day. Code runs locally, but not on > playground. It also had a sleep in a goroutine. > > > > fatal error: all goroutines are asleep - deadlock! > > > But if you look at the stack traces, you see multiple routines (sampled) > like: > > goroutine 1 [sleep]: > runtime.goparkunlock(...) > /usr/local/go/src/runtime/proc.go:307 > time.Sleep(0x3e8, 0x0) > /usr/local/go/src/runtime/time.go:105 +0x1c0 > main.main() > /tmp/sandbox327672725/prog.go:81 +0x140 > > goroutine 5 [sleep]: > runtime.goparkunlock(...) > /usr/local/go/src/runtime/proc.go:307 > time.Sleep(0x1, 0x0) > /usr/local/go/src/runtime/time.go:105 +0x1c0 > main.producer(0x430150, 0x40a0e0) > /tmp/sandbox327672725/prog.go:49 +0x60 > created by main.main > /tmp/sandbox327672725/prog.go:73 +0xe0 > > > These routines are asleep, not blocked. They will awake from sleep > (eventually) - so there cannot be a deadlock. > > I am assuming this is a limitation of the Go playground back-end, but I > can’t see it documented anywhere? Also, I’m not sure why this limitation > would exist, since if all the routines are asleep or blocked, it is > consuming no resources. > > Ideas? > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/C7B46199-05EA-47C1-9594-200E2DD36F99%40ix.netcom.com > . > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAMV2RqpyK54ZsUJAPF%3D8Jk2GUjAXL%2B6E5-htX7R-wSuM_6MNVg%40mail.gmail.com > . > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/F957AAC7-A4F9-45D5-A80E-2BA788C6C721%40ix.netcom.com > <https://groups.google.com/d/msgid/golang-nuts/F957AAC7-A4F9-45D5-A80E-2BA788C6C721%40ix.netcom.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAK4xykX%3D1vALy1GDwAicJpN05nKMM60R7WMz6MBg97%2BLT%3DGZBg%40mail.gmail.com.