Skip to content

Conversation

@mtmk
Copy link
Member

@mtmk mtmk commented Oct 7, 2024

No description provided.

{
throw new OperationCanceledException();
}
await _semLock.Writer.WriteAsync(0, cancellationToken).AsTask().WaitAsync(_defaultCommandTimeout, cancellationToken).ConfigureAwait(false);
Copy link
Collaborator

@to11mtm to11mtm Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a problem you may run into here is that due to the semantics of WaitAsync(), the operation may have cancelled due to timeout -but- the operation could still go through.

Work-around should be to use a CancellationTokenSource.LinkedTokenSource(cancellationToken) and then CancelAfter() on that before passing that token into the WriteAsync()... Just need to dispose the LTS when done

Replaced WaitAsync with CancellationTokenSource for more precise control over command timeouts. This ensures that operations are cancelled correctly after the default timeout and improves overall reliability when handling cancellation tokens.
@mtmk mtmk self-assigned this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants