Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel magick #266

Closed
Feresey opened this issue Apr 19, 2020 · 1 comment
Closed

Channel magick #266

Feresey opened this issue Apr 19, 2020 · 1 comment
Labels
Milestone

Comments

@Feresey
Copy link

Feresey commented Apr 19, 2020

I noticed a strange work with channels in the file bot.go

func (b *Bot) Start() {
       ...
	stopPoller := make(chan struct{})

	go b.Poller.Poll(b, b.Updates, stopPoller)

	for {
		select {
		case upd := <-b.Updates:
			b.incomingUpdate(&upd)
		case <-b.stop:
			stopPoller <- struct{}{} // why not close?
		case <-stopPoller:                   // read from same channel
			return
		}
	}
}

And how this channel uses in long poller:

func (p *LongPoller) Poll(b *Bot, dest chan Update, stop chan struct{}) {
	go func(stop chan struct{}) {
		<-stop       // read again
		close(stop) // and close???
	}(stop)
        ...
}
@demget demget added the bug label Apr 26, 2020
@demget demget added this to the v2.1 milestone Apr 26, 2020
@demget
Copy link
Collaborator

demget commented Apr 26, 2020

LongPoller is now stoppable. c14c51a

@demget demget closed this as completed Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants