1

So I'm using the new process Initialization to run a python script from c# and print the output to the console. The python file contains some modules and it worked printing the Output data as well as the Error data but one 429 error message caused by a module in python does not appear there, strangely other errors (even from the same module) work and show up when I run the code in c#.

The last hours I've tried a lot of things to fix this but can't find anything related. Does anyone possibly know an answer for this / what makes the difference that one shows up and the other don't?

The code looks like this:

   static void Main(string[] args)
    {
        Process p = new Process();

        p.StartInfo.FileName = @"C:\Python38\python.exe";
        p.StartInfo.Arguments = @"C:\Users\Admin\Desktop\file.py";

        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.RedirectStandardError = true;
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.CreateNoWindow = true;

        p.EnableRaisingEvents = true;

        p.OutputDataReceived += new DataReceivedEventHandler((s, e) => 
        { 
            Console.WriteLine(e.Data); 
        });
        p.ErrorDataReceived += new DataReceivedEventHandler((s, e) =>
        {
            Console.WriteLine(e.Data);
        });

        p.Start();
        p.BeginOutputReadLine();
        p.BeginErrorReadLine();

        Console.Read();
    }

And the missing error looks like this: JSON Query ... 429 Too Many Requests: redirected to login [retrying; skip with ^C]

Sadly the error is hardy reproducible even with the python file.

request
  • 450
  • 1
  • 4
  • 10

0 Answers0