Avoid OOM in doctest CI (#24139)

* fix

* fix

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar
2023-06-10 09:47:38 +02:00
committed by GitHub
parent 0d217f428f
commit 8f093fb799

View File

@@ -1870,9 +1870,18 @@ def preprocess_string(string, skip_cuda_tests):
): ):
is_cuda_found = True is_cuda_found = True
break break
modified_string = "" modified_string = ""
if not is_cuda_found: if not is_cuda_found:
modified_string = "".join(codeblocks) modified_string = "".join(codeblocks)
if ">>>" in modified_string:
lines = modified_string.split("\n")
indent = len(lines[-1]) - len(lines[-1].lstrip())
cleanup = ">>> import gc; gc.collect() # doctest: +IGNORE_RESULT"
modified_string += "\n" + " " * indent + cleanup
return modified_string return modified_string