From a8225b0e7dc130360c873274196cbe4cc3514acd Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 5 Jan 2022 15:15:11 -0500 Subject: [PATCH] let setrlimit fail :/ --- src/_zkapauthorizer/_stack.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/_zkapauthorizer/_stack.py b/src/_zkapauthorizer/_stack.py index c6d5533..abb725d 100644 --- a/src/_zkapauthorizer/_stack.py +++ b/src/_zkapauthorizer/_stack.py @@ -36,7 +36,12 @@ def less_limited_stack(): More precisely, the soft stack limit is raised to the hard limit. """ soft, hard = getrlimit(RLIMIT_STACK) - # We can raise the soft limit to the hard limit and no higher. - setrlimit(RLIMIT_STACK, (hard, hard)) - yield - setrlimit(RLIMIT_STACK, (soft, hard)) + try: + # We can raise the soft limit to the hard limit and no higher. + setrlimit(RLIMIT_STACK, (hard, hard)) + except ValueError: + # Well, not on macOS: https://bugs.python.org/issue34602 + yield + else: + yield + setrlimit(RLIMIT_STACK, (soft, hard)) -- GitLab