From da8de84a613a1d2515363a9ab5a270a73907b542 Mon Sep 17 00:00:00 2001 From: Trevor Bergeron Date: Mon, 1 Apr 2024 19:52:22 +0000 Subject: [PATCH] fix: Respect hard stack size limit and swallow limit change exception. --- bigframes/pandas/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bigframes/pandas/__init__.py b/bigframes/pandas/__init__.py index b6476c5eb8..fc008f36e5 100644 --- a/bigframes/pandas/__init__.py +++ b/bigframes/pandas/__init__.py @@ -714,9 +714,13 @@ def to_datetime( # which the applicable limit is now hard coded. See: # https://github.com/python/cpython/issues/112282 sys.setrecursionlimit(max(10000000, sys.getrecursionlimit())) -resource.setrlimit( - resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY) -) + +soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_STACK) +if soft_limit < hard_limit or hard_limit == resource.RLIM_INFINITY: + try: + resource.setrlimit(resource.RLIMIT_STACK, (hard_limit, hard_limit)) + except Exception: + pass # Use __all__ to let type checkers know what is part of the public API. __all___ = [