Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit 5410f26

Browse files
committed
The stdout and stderr of the compilations is limited to 1 KiB
1 parent 48eb26c commit 5410f26

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

cpp/frontend/python/frontend.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ PYBIND11_MODULE(task_maker_frontend, m) {
105105
pybind11::class_<frontend::File>(m, "File")
106106
.def("getContentsAsString",
107107
[](frontend::File& f, std::function<void(std::string)> cb,
108-
uint64_t limit = 0xffffffffffffffff) {
108+
uint64_t limit) {
109109
f.getContentsAsString(
110110
[cb = destroy_with_gil(cb)](std::string s) mutable {
111111
pybind11::gil_scoped_acquire acquire;
@@ -119,10 +119,10 @@ PYBIND11_MODULE(task_maker_frontend, m) {
119119
},
120120
limit);
121121
},
122-
"callback"_a, "limit"_a)
122+
"callback"_a, "limit"_a = 0xffffffffffffffff)
123123
.def("getContentsAsBytes",
124124
[](frontend::File& f, std::function<void(pybind11::bytes)> cb,
125-
uint64_t limit = 0xffffffffffffffff) {
125+
uint64_t limit) {
126126
f.getContentsAsString(
127127
[cb = destroy_with_gil(cb)](std::string s) mutable {
128128
pybind11::gil_scoped_acquire acquire;
@@ -136,7 +136,7 @@ PYBIND11_MODULE(task_maker_frontend, m) {
136136
},
137137
limit);
138138
},
139-
"callback"_a, "limit"_a)
139+
"callback"_a, "limit"_a = 0xffffffffffffffff)
140140
.def("getContentsToFile", &frontend::File::getContentsToFile, "path"_a,
141141
"overwrite"_a = true, "exist_ok"_a = true);
142142

python/remote/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def __init__(self,
9090
store_stderr: bool = False,
9191
store_stdout_bytes: bool = False,
9292
store_stderr_bytes: bool = False,
93+
stdout_limit: int = 0xffffffffffffffff,
94+
stderr_limit: int = 0xffffffffffffffff,
9395
inputs: Dict[str, File] = None,
9496
outputs: Iterable[Union[str, Tuple[str, bool]]] = ()):
9597
"""
@@ -242,13 +244,17 @@ def __init__(self,
242244
self._outputs[path] = self._execution.output(path, executable)
243245

244246
if self.store_stdout:
245-
self.stdout.getContentsAsString(self._get_stdout_internal)
247+
self.stdout.getContentsAsString(self._get_stdout_internal,
248+
stdout_limit)
246249
if self.store_stderr:
247-
self.stderr.getContentsAsString(self._get_stderr_internal)
250+
self.stderr.getContentsAsString(self._get_stderr_internal,
251+
stderr_limit)
248252
if self.store_stdout_bytes:
249-
self.stdout.getContentsAsBytes(self._get_stdout_bytes_internal)
253+
self.stdout.getContentsAsBytes(self._get_stdout_bytes_internal,
254+
stdout_limit)
250255
if self.store_stderr_bytes:
251-
self.stderr.getContentsAsBytes(self._get_stderr_bytes_internal)
256+
self.stderr.getContentsAsBytes(self._get_stderr_bytes_internal,
257+
stderr_limit)
252258

253259
self._execution.notifyStart(self._notify_start_internal)
254260
# getResult should be the last thing done on _execution

python/source_file.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from task_maker.task_maker_frontend import File
1010
from typing import Optional, Dict, List
1111

12+
COMPILATION_STDERR_LIMIT = 1024
13+
1214

1315
def is_executable(path: str) -> bool:
1416
"""
@@ -157,6 +159,8 @@ def _compile(self):
157159
},
158160
inputs=inputs,
159161
outputs=[(self.exe_name, True)],
162+
stdout_limit=COMPILATION_STDERR_LIMIT,
163+
stderr_limit=COMPILATION_STDERR_LIMIT,
160164
store_stderr=True,
161165
store_stdout=True)
162166
self.executable = self.compilation.output(self.exe_name)

0 commit comments

Comments
 (0)