How to read 1MB of input from stdin?

I tried using this code How to read exactly N bytes from stdin in Native Messaging host? - #2 by Rosuav.

I can read input to stdin with length 1045001 (new Array(209000)) from JavaScript using C, C++, JavaScript (QuickJS; Deno; Node.js). I am trying to achieve the same using Python; which currently exits when input is new Array(174763).