Repository navigation
Add GetConsumingEnumerableOrNull for blocking collections - #10100
Merged
Martin-Molinero merged 1 commit intoNov 12, 2026
Merged
Martin-Molinero merged 1 commit into
Martin-Molinero merged 1 commit into
Conversation
Calling Any() on a BlockingCollection's consuming enumerable removes its first item and drops it. The same check-then-return pattern is copied in several data downloaders, so add one extension that waits for the first item, returns null when the collection completes adding without an item, and otherwise returns every item, the first one included. CanonicalDataDownloaderDecorator now uses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 12, 2026
Closed
Canonical option downloads discard the first history point
QuantConnect/Lean.DataSource.ThetaData#22
Closed
This was referenced Nov 12, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
Extensions.GetConsumingEnumerableOrNull<T>(this BlockingCollection<T>). It waits for the first item, returnsnullif the collection completes adding without an item, and otherwise returns an enumerable that consumes every item, the first one included.CanonicalDataDownloaderDecorator.GetContractsDatanow uses it in place of its inlineTryTake+Prependfrom #10096. Its behavior is unchanged.Related Issue
Follow-up to #10002 / #10096. The same
Any()on a consuming enumerable drops the first item in:Once they build against a Lean with this helper, each fix is one call.
Motivation and Context
Calling
Any()onBlockingCollection.GetConsumingEnumerable()removes the first item and drops it. The same check-then-return block was copied into several downloaders, so one shared helper replaces the per-repository fixes.Requires Documentation Change
No.
How Has This Been Tested?
New tests in
ExtensionsTests:null.null.I swapped the helper body for the old
Any()check to confirm the tests catch the bug: 4 of the new tests fail, plus 2 of the existingCanonicalDataDownloaderDecoratorTests(6 failed, 32 passed). With the helper, all pass.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>🤖 Generated with Claude Code