Re: [go-nuts] scanner.Scan is holding my goroutine ;(

2018-12-13 Thread 'Kevin Malachowski' via golang-nuts
Can you post a short, self-contained (compile-able and runnable) example which 
shows the problem? Preferably hosted on play.golang.org for easy sharing and 
editing.

If the scanner is reading from a reader which has been closed (returns io.EOF), 
the sc.Scan should return false (and the sc.Err would return nil). Depending on 
the surrounding code, that should mean that the for loop you presented should 
terminate. It's possible the code which contains your bug has not been shared, 
so posting a self-contained reproduction program would help move the 
conversation forward.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] scanner.Scan is holding my goroutine ;(

2018-12-13 Thread Dan Kortschak
Can you wrap the call to scanner.Scan in a func that has access to the
ccn context and returns false when it's closed?

On Thu, 2018-12-13 at 14:04 -0800, Ivan Korjavin wrote:
> I have a goroutenie with  scanner.Scan
> It looks like:
> 
> ```
> cnn.SetReadDeadline(time.Now().Add(c.rTimeout)) // 10s
> scanner := bufio.NewScanner(cnn)
> for scanner.Scan() {
> ...
> }
> ```
> cnn is a net.Conn there
> 
> My problem is when I call cnn.Close() (and I tried 
> cnn.SetReadDeadline(time.Now()) in addition as well)
> this scanner.Scan is still running and running and running.
> 
> I would like to close it immediately, but can't find a way how.
> 
> 
> Please, help me!
> 

-- 
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.
For more options, visit https://groups.google.com/d/optout.