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

Add retries to ModulesAreDisposedWhenProcessIsDisposed #68104

Merged
merged 2 commits into from
Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;
using System.Linq;
using Microsoft.DotNet.RemoteExecutor;
using Xunit;
Expand Down Expand Up @@ -76,7 +77,15 @@ public void ModulesAreDisposedWhenProcessIsDisposed()
{
Process process = CreateDefaultProcess();

ProcessModuleCollection modulesCollection = process.Modules;
// Very rarely, this call will fail with ERROR_PARTIAL_COPY; it only happened
// so far on this particular test, the only one that creates a new process.
// Assumption is that we need to give a little extra time.
ProcessModuleCollection modulesCollection = null;
RetryHelper.Execute(() =>
{
modulesCollection = process.Modules;
}, maxAttempts: 5, backoffFunc: null, retryWhen: e => e.GetType() == typeof(Win32Exception));

int expectedCount = 0;
int disposedCount = 0;
foreach (ProcessModule processModule in modulesCollection)
Expand Down