public static ReplWindowProxy Prepare(
            ReplWindowProxySettings settings,
            bool useIPython = false
            )
        {
            settings.AssertValid();

            var             app    = settings.CreateApp();
            ReplWindowProxy result = null;

            try {
                result = OpenInteractive(app, settings, useIPython ? "IPython" : "Standard");
                app    = null;

                for (int retries = 10; retries > 0; --retries)
                {
                    result.Reset();
                    result.ClearScreen();
                    result.ClearInput();

                    try {
                        var task = result.ExecuteText("print('READY')");
                        Assert.IsTrue(task.Wait(useIPython ? 30000 : 10000), "ReplWindow did not initialize in time");
                        if (!task.Result.IsSuccessful)
                        {
                            continue;
                        }
                    } catch (TaskCanceledException) {
                        continue;
                    }

                    result.WaitForTextEnd("READY", ">");
                    if (result.TextView.TextBuffer.CurrentSnapshot.Lines
                        .Any(l => l.GetText().Contains("Error using selected REPL back-end")) &&
                        useIPython)
                    {
                        Assert.Inconclusive("IPython is not available");
                    }
                    result.ClearScreen();
                    return(result);
                }
                Assert.Fail("ReplWindow did not initialize");
                return(null);
            } finally {
                if (app != null)
                {
                    app.Dispose();
                }
            }
        }
 public SessionHolder(T session, ReplWindowProxy owner)
 {
     Assert.IsNotNull(session);
     Session = session;
     _owner  = owner;
 }