MCPcopy Create free account
hub / github.com/apache/arrow / do_GET

Method do_GET

python/scripts/run_emscripten_tests.py:43–110  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

41 return
42
43 def do_GET(self) -> bytes | None:
44 if self.path.endswith(PYARROW_WHEEL_PATH.name):
45 self.send_response(200)
46 self.send_header("Content-type", "application/x-zip")
47 self.end_headers()
48 with PYARROW_WHEEL_PATH.open(mode="rb") as wheel:
49 self.copyfile(wheel, self.wfile)
50 elif self.path.endswith("/test.html"):
51 body = b"""
52 <!doctype html>
53 <html>
54 <head>
55 <script>
56 window.python_done_callback = undefined;
57 window.python_logs = [];
58 function capturelogs(evt) {
59 if ('results' in evt.data) {
60 if (window.python_done_callback) {
61 let callback = window.python_done_callback;
62 window.python_done_callback = undefined;
63 callback({result:evt.data.results});
64 }
65 }
66 if ('print' in evt.data) {
67 evt.data.print.forEach((x)=>{window.python_logs.push(x)});
68 }
69 }
70 window.pyworker = new Worker("worker.js");
71 window.pyworker.onmessage = capturelogs;
72 </script>
73 </head>
74 <body></body>
75 </html>
76 """
77 self.send_response(200)
78 self.send_header("Content-type", "text/html")
79 self.send_header("Content-length", len(body))
80 self.end_headers()
81 self.copyfile(BytesIO(body), self.wfile)
82 elif self.path.endswith("/worker.js"):
83 body = b"""
84 importScripts("./pyodide.js");
85 onmessage = async function (e) {
86 const data = e.data;
87 if (!self.pyodide) {
88 self.pyodide = await loadPyodide();
89 }
90 function do_print(arg) {
91 let databytes = Array.from(arg);
92 self.postMessage({print:databytes});
93 return databytes.length;
94 }
95 self.pyodide.setStdout({write:do_print,isatty:data.isatty});
96 self.pyodide.setStderr({write:do_print,isatty:data.isatty});
97
98 await self.pyodide.loadPackagesFromImports(data.python);
99 let results = await self.pyodide.runPythonAsync(data.python);
100 self.postMessage({results});

Callers

nothing calls this directly

Calls 3

end_headersMethod · 0.95
lenFunction · 0.85
openMethod · 0.45

Tested by

no test coverage detected