Re: [go-nuts] Is there any way to produce etcd watch chan be closed

2022-03-27 Thread 袁成若
Ok, thanks.

Ian Lance Taylor  于2022年3月26日周六 02:45写道:

> On Fri, Mar 25, 2022 at 11:41 AM 袁成若  wrote:
> >
> > I met a problem about etcd watch channel. seems that be closed,  but i
> can not reproduce it.
> >
> > like this:
> >
> > ```
> > for {
> >  ach := etcdClientV3.Watch(context.Background(), "/test",
> clientv3.WithPrefix())
> >  for {
> >   select {
> >  case wch := <- ach {
> >fmt.Println("recv chan")
> >  }
> >   }
> >  }
> > }
> > ```
> > the program print recv chan all the time. but I cannot reproduce  it ,
> Is there any way to reproduce it
>
> It sounds like you are describing a problem with the
> https://github.com/etcd-io/etcd/ package.  I suggest that you ask
> there.
>
> Ian
>

-- 
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/CAFTq8SfPhqwzD302QOQV022vhsjfGR%3D6%3DR_RGRkBvO63XO-U2g%40mail.gmail.com.


Re: [go-nuts] Is there any way to produce etcd watch chan be closed

2022-03-25 Thread Sam Hughes
 As written above, if that's the main thread, it is guaranteed to freeze in 
a deadlock every time. I don't see a goroutine kicked off, so I'm assuming 
you're trying to run that on the main thread, and you will be 100%, always, 
forever stuck on the `case wch := <- ach {` line.

Channel reads are blocking, if there's nothing in the buffer. You might 
have omitted it for brevity, but so I read that as if it's on the main 
thread for the program. You want goroutines to block while awaiting a 
receivable channel, typically. If you're receiving on the main thread, you 
need to add a default case that will not block.. This is a good explanation 
of the issue: https://golangbyexample.com/select-default-case-go/

On Friday, March 25, 2022 at 1:45:48 PM UTC-5 Ian Lance Taylor wrote:

> On Fri, Mar 25, 2022 at 11:41 AM 袁成若  wrote:
> >
> > I met a problem about etcd watch channel. seems that be closed, but i 
> can not reproduce it.
> >
> > like this:
> >
> > ```
> > for {
> > ach := etcdClientV3.Watch(context.Background(), "/test", 
> clientv3.WithPrefix())
> > for {
> > select {
> > case wch := <- ach {
> > fmt.Println("recv chan")
> > }
> > }
> > }
> > }
> > ```
> > the program print recv chan all the time. but I cannot reproduce it , Is 
> there any way to reproduce it
>
> It sounds like you are describing a problem with the
> https://github.com/etcd-io/etcd/ package. I suggest that you ask
> there.
>
> Ian
>

-- 
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/6c0b5e4b-9959-45cb-a476-fca3a3d2d72dn%40googlegroups.com.


Re: [go-nuts] Is there any way to produce etcd watch chan be closed

2022-03-25 Thread Ian Lance Taylor
On Fri, Mar 25, 2022 at 11:41 AM 袁成若  wrote:
>
> I met a problem about etcd watch channel. seems that be closed,  but i can 
> not reproduce it.
>
> like this:
>
> ```
> for {
>  ach := etcdClientV3.Watch(context.Background(), "/test", 
> clientv3.WithPrefix())
>  for {
>   select {
>  case wch := <- ach {
>fmt.Println("recv chan")
>  }
>   }
>  }
> }
> ```
> the program print recv chan all the time. but I cannot reproduce  it , Is 
> there any way to reproduce it

It sounds like you are describing a problem with the
https://github.com/etcd-io/etcd/ package.  I suggest that you ask
there.

Ian

-- 
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/CAOyqgcXeHHdVBmYj7FYL1yHSDW%2BvgyjPnFLR1EBxE6Ag3sSo%3DQ%40mail.gmail.com.


[go-nuts] Is there any way to produce etcd watch chan be closed

2022-03-25 Thread 袁成若
I met a problem about etcd watch channel. seems that be closed,  but i can 
not reproduce it.

like this: 

```
for {
 ach := etcdClientV3.Watch(context.Background(), "/test", 
clientv3.WithPrefix())
 for {
  select {
 case wch := <- ach {
   fmt.Println("recv chan")
 }
  }
 }
}
```
the program print recv chan all the time. but I cannot reproduce  it , Is 
there any way to reproduce it

-- 
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/d7c2a224-1124-4c77-8627-d34a08ef3035n%40googlegroups.com.