Skip to content

Commit 4ede3b1

Browse files
authored
Feat: improve logging and thread safety in data provider (#13)
* feat: improve logging and thread safety in data provider * feat: make _lock static in DataSetSpecifications
1 parent a47ae5f commit 4ede3b1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

QuantConnect.DataBento/DataBentoHistoryProivder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public override void Initialize(HistoryProviderInitializeParameters parameters)
7373
{
7474
_invalidSecurityTypeWarningFired = true;
7575
Log.Trace($"{nameof(DataBentoProvider)}.{nameof(GetHistory)}:" +
76-
$"Unsupported SecurityType '{historyRequest.Symbol.SecurityType}' for symbol '{historyRequest.Symbol}'.");
76+
$"History request not supported for symbol '{historyRequest.Symbol}' (SecurityType: {historyRequest.Symbol.SecurityType}, Canonical: {historyRequest.Symbol.IsCanonical()}).");
7777
}
7878
return null;
7979
}

QuantConnect.DataBento/Models/DataSetSpecifications.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static class PredefinedDataSets
5656
/// </summary>
5757
public class DataSetSpecifications
5858
{
59+
private static readonly Lock _lock = new();
5960
/// <summary>
6061
/// Internal flag to ensure the delay warning message is only generated once.
6162
/// </summary>
@@ -117,13 +118,21 @@ public bool TryGetDelayWarningMessage(out string? message)
117118
{
118119
return false;
119120
}
120-
message = $"Dataset [{DataSetID}] historical data information:\n" +
121+
lock (_lock)
122+
{
123+
if (_delayWarningFired)
124+
{
125+
return false;
126+
}
127+
128+
message = $"Dataset [{DataSetID}] historical data information:\n" +
121129
$"- Users with a live license: delayed by approximately {HistoricalDelayWithLicense}." +
122130
$"For access to more recent data, use the intraday replay feature of the live data client.\n" +
123131
$"- Users without a license: delayed by {HistoricalDelayWithoutLicense}.\n" +
124132
$"- More information: {Link} (go to the 'Specifications' tab)";
125133

126-
_delayWarningFired = true;
127-
return true;
134+
_delayWarningFired = true;
135+
return true;
136+
}
128137
}
129138
}

0 commit comments

Comments
 (0)