Skip to content

A cancellation doesn't work in some cases and app hangs. #351

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 2 commits into from

Conversation

gurustron
Copy link

@gurustron gurustron commented Oct 15, 2018

I've played a little bit with an issue raised here it seems that without setting NamedPipeClientStream to PipeOptions.Asynchronous after disposing stream it endlessly waits in PipeStream.Read for local Windows connection.

Steps to repro:

create console app (NET71, .NETCORE) on Windows machine with empty Docker.

    public static async Task Main(string[] args)
    {
        var cts = new CancellationTokenSource();

        var _client = new DockerClientConfiguration().CreateClient();
        cts.CancelAfter(3000);
        cts.Token.Register(() => { Console.WriteLine("Cancel happened"); });
        var task = _client.System.MonitorEventsAsync(new ContainerEventsParameters(), new Progress(), cts.Token);
        await task.ConfigureAwait(false);
        Console.WriteLine("finished");
        Console.ReadKey();
    }
    
    class Progress : IProgress<JSONMessage>
    {
        internal Action<JSONMessage> _onCalled;

        void IProgress<JSONMessage>.Report(JSONMessage value)
        {
            _onCalled(value);
        }
    }

@msftclas
Copy link

msftclas commented Oct 15, 2018

CLA assistant check
All CLA requirements met.

@marcelltoth
Copy link

I'm running into the same issue.

It looks like microsoft kind of ignores this repo, in the meanwhile does anyone have a good workaround? (Other than just keeping all my tasks alive, which does not sound great.)

AndrewKostousov added a commit to AndrewKostousov/Docker.DotNet that referenced this pull request May 19, 2020
@dgvives
Copy link
Contributor

dgvives commented Jan 1, 2021

Hello @gurustron
I'm going through all unmerged PR, my intention is to create a PR with code compatible with latest Docker API.
There are outdated models in current definition and this is causing automatic tests to fail within the CI/CD pipeline, causing PR to not be even reviewed.

Would you check if MonitorEventsAsync is working? I haven't managed to

@jterry75
Copy link
Contributor

jterry75 commented Jan 4, 2021

@dgvives - Unrelated to this PR but if you are going to do that I would prefer that we just remove tools/specgen anymore and just manually update the models. Docker changed how all of this worked long ago when the broke the branches into EE/CE and made specgen less than helpful. I'm all for updating the models I just think that specgen is not worth the effort anymore. I no longer have the time to really contribute here but I am happy to merge PR's if you want to do this work. Thanks!

@galvesribeiro
Copy link
Member

galvesribeiro commented Jan 4, 2021 via email

@dgvives
Copy link
Contributor

dgvives commented Jan 4, 2021

@jterry75 @galvesribeiro Some of the models overridden on modeldefs.go are missing the required rest tag for correct model generation. I've updated some I found broken, but not all of them.

Code generation using specgen is what I've used. All the generated models are based on specgen details, as I think they should be at least for now.

Continue on #480

@gurustron
Copy link
Author

gurustron commented Jan 13, 2021

@dgvives I will try to take a look into it this week.

@dgvives
Copy link
Contributor

dgvives commented Jan 31, 2021

@gurustron I confirm these changes have been incorporated in the last merge, MonitorEventsAsync can be cancelled
Current solution is based on #343 using an extension method and throwing an exception whenever token gets cancellated.

However, this behaviour is not the most appropriate as it produces slightly different results when running tests on different environments. I expect to submit a PR with a different approach to this, and include references to yours and others' work as contributor

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.

6 participants