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

Method do_GET

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

Source from the content-addressed store, hash-verified

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