Skip to content
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

[EXPERIMENT] Channel lock experiment #646

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

[EXPERIMENT] Channel lock experiment #646

wants to merge 3 commits into from

Conversation

mtmk
Copy link
Collaborator

@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.

2 participants