-
Notifications
You must be signed in to change notification settings - Fork 90
Check if channel receive will succeed using len instead of a select statement. #292
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1192,18 +1192,16 @@ func (t *tokenProcessor) iterateResponse() error { | |
| func (t tokenProcessor) nextToken() (tokenStruct, error) { | ||
| // we do this separate non-blocking check on token channel to | ||
| // prioritize it over cancellation channel | ||
| select { | ||
| case tok, more := <-t.tokChan: | ||
| err, more := tok.(error) | ||
| if more { | ||
| if len(t.tokChan) > 0 { | ||
| tok := <-t.tokChan | ||
| err, ok := tok.(error) | ||
| if ok { | ||
| t.sess.LogF(t.ctx, msdsn.LogDebug, "nextToken returned an error:"+err.Error()) | ||
| // this is an error and not a token | ||
| return nil, err | ||
| } else { | ||
| return tok, nil | ||
| } | ||
| default: | ||
| // there are no tokens on the channel, will need to wait | ||
| } | ||
|
Comment on lines
1195
to
1210
|
||
|
|
||
| select { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.