Skip to content

time: the time.After channel does not close when reusing it  #16259

@blackbeans

Description

@blackbeans

i want use the same channel of time.After for waiting some response timeout.
but when i reuse the channel to read ,it blocks the current goroutine.

Now ,i use another way to solve the problem.

latch := make(chan time.Time, 1)
t := time.AfterFunc(timeout, func() {
    close(latch)
})

defer t.Stop()
tch := (<-chan time.Time)(latch)

//wating for response
for g, f := range self.futures {
    resp, err := f.Get(tch)
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions