Skip to content

Add a WatchAsync method. #308

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

Closed
wants to merge 1 commit into from

Conversation

brendandburns
Copy link
Contributor

Closes #301

@brendandburns brendandburns requested a review from tg123 September 27, 2019 04:35
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 27, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 27, 2019
@brendandburns brendandburns force-pushed the watch branch 2 times, most recently from 53b3ed6 to 542df90 Compare September 27, 2019 04:37
var podlistResp = client.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).Result;
using (podlistResp.Watch<V1Pod>((type, item) =>
var podlistResp = client.ListNamespacedPodWithHttpMessagesAsync("default", watch: true);
using (podlistResp.WatchAsync<V1Pod, V1PodList>((type, item) =>
Copy link
Member

Choose a reason for hiding this comment

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

do you want

using (await ...)

here using is to dispose Task

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, because the whole goal was to print the 'ctl-c to cancel' before the wait completes, but perhaps I should drop the 'using' part..

Copy link
Member

Choose a reason for hiding this comment

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

await WatchAsync creates a new Watcher which will not block running to code inside using

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fwiw, you can't use await here because then the Main would have to be async and dotnet doesn't like that. I tried using .Result but it hangs w/o printing the ctrl-c stuff.

I'm open to suggestions, but for now I think this is the best we can do (or we could just remove the using syntax...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I just rewrote the code to avoid the using directive and to call Dispose directly.

Copy link
Member

Choose a reason for hiding this comment

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

sorry I finally understand the issue I did not look into #301 carefully before
please see #313 for my proposal

@tg123 tg123 self-requested a review September 28, 2019 13:26
var podlistResp = client.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).Result;
using (podlistResp.Watch<V1Pod>((type, item) =>
var podlistResp = client.ListNamespacedPodWithHttpMessagesAsync("default", watch: true);
using (podlistResp.WatchAsync<V1Pod, V1PodList>((type, item) =>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
using (podlistResp.WatchAsync<V1Pod, V1PodList>((type, item) =>
using (await podlistResp.WatchAsync<V1Pod, V1PodList>((type, item) =>

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 2, 2019
@brendandburns
Copy link
Contributor Author

Comment addressed, please take another look.

@tg123
Copy link
Member

tg123 commented Dec 20, 2019

close via #313

@tg123 tg123 closed this Dec 20, 2019
@k8s-ci-robot
Copy link
Contributor

@brendandburns: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Watcher creation blocks until first change notification available
3 participants