Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: Respect hard stack size limit and swallow limit change exception. #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions 10 bigframes/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason we want to pass all the exceptions? Generally we should never suppress all exceptions. https://g3doc.corp.google.com/eng/doc/devguide/py/style/index.md?cl=head#s2.4-exceptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increasing stack limits isn't a hard requirement for bigframes to work. It merely reduces the likelihood of overflowing stack memory for deeply nested trees algorithms later on. From looking at other codebases that change resource limits, it can be rather error-prone due to each platform's inconsistency/limits/bugs and its hard to guarantee that the operation will succeed, so wanted to play it safe.

pass

# Use __all__ to let type checkers know what is part of the public API.
__all___ = [
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.