Skip to content

Commit

Permalink
Re-add check if token is cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-lf committed Mar 21, 2024
1 parent 21915dc commit 7185f79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 0 additions & 9 deletions Snowflake.Data.Tests/IntegrationTests/SFDbCommandIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,11 @@ public async Task TestAsyncExecCancelWhileGettingResultsAsync()

// Act
cancelToken.Cancel();
#if NET471
var thrown = Assert.ThrowsAsync<OperationCanceledException>(async () =>
await cmd.GetResultsFromQueryIdAsync(queryId, cancelToken.Token).ConfigureAwait(false));
#else
var thrown = Assert.ThrowsAsync<TaskCanceledException>(async () =>
await cmd.GetResultsFromQueryIdAsync(queryId, cancelToken.Token).ConfigureAwait(false));
#endif

// Assert
#if NET472
Assert.IsTrue(thrown.Message.Contains("A task was canceled"));
#else
Assert.IsTrue(thrown.Message.Contains("The operation was canceled"));
#endif
}

await conn.CloseAsync(CancellationToken.None).ConfigureAwait(false);
Expand Down
6 changes: 6 additions & 0 deletions Snowflake.Data/Client/SnowflakeDbCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ internal async Task RetryUntilQueryResultIsAvailable(string queryId, Cancellatio
QueryStatus status;
while (true)
{
if (cancellationToken.IsCancellationRequested)
{
logger.Debug("Cancellation requested for getting results from query id");
cancellationToken.ThrowIfCancellationRequested();
}

Check warning on line 373 in Snowflake.Data/Client/SnowflakeDbCommand.cs

View check run for this annotation

Codecov / codecov/patch

Snowflake.Data/Client/SnowflakeDbCommand.cs#L373

Added line #L373 was not covered by tests

status = isAsync ? await GetQueryStatusAsync(queryId, cancellationToken) : GetQueryStatus(queryId);

if (!QueryStatuses.IsStillRunning(status))
Expand Down

0 comments on commit 7185f79

Please sign in to comment.