Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am using RedirectStandardError and RedirectStandardOutput of ProcessStartInfo to grap output and errors of python programs. This works correct when I run the test server using
Python
app.run(host="0.0.0.0", port=8080)
. but when I use waitress or wsgiserver I got no output.

Any suggestions?

the C# code

C#
static Process ExecuteCommand(string name, string file, string args)
        {
            var processInfo = new ProcessStartInfo(file, args);
            processInfo.CreateNoWindow = true;
            processInfo.UseShellExecute = false;
            processInfo.RedirectStandardError = true;
            processInfo.RedirectStandardOutput = true;

            var process = Process.Start(processInfo);

            process.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>
                LogOutput(name, e.Data,false);

            process.BeginOutputReadLine();

            process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) =>
                LogOutput(name, e.Data, true);

            process.BeginErrorReadLine();

            return process;
        }

        private static void LogOutput(string name, string data, bool isError)
        {
            Console.WriteLine(string.Format("at {0:d/M/yyyy H\\:m\\:s} {1}:{2}{3}",DateTime.Now, name, (isError ? "(error) " : ""), data));

        }


What I have tried:

i have tried waitress or wsgiserver
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900