This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: ValueError when using resource.setrlimit on macOS Catalina
Type: behavior Stage: resolved
Components: macOS Versions: Python 3.7
Status: closed Resolution: duplicate
Dependencies: Superseder: python3 resource.setrlimit strange behaviour under macOS
View: 34602
Assigned To: Nosy List: corona10, morioprog, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2020-05-05 13:57 by morioprog, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg368149 - (view) Author: Shota Iwamoto (morioprog) Date: 2020-05-05 13:57
Hello, I'm having trouble when using `resource.setrlimit` on macOS.

import resource
resource.setrlimit(resource.RLIMIT_STACK, resource.getrlimit(resource.RLIMIT_STACK))

Running this code gives the following error:

Traceback (most recent call last):
  File "", line 2, in <module>
    resource.setrlimit(resource.RLIMIT_STACK, resource.getrlimit(resource.RLIMIT_STACK))
ValueError: current limit exceeds maximum limit

I ran the same code in my linux environment and it worked.

* macOS Catalina 10.15.4 (19E287)
* `python --version` : Python 3.7.7

msg368214 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-06 00:00
See the long discussion in Issue34602 for more details. The investigation there showed that there are now conditions when running in newer versions of macOS (apparently as of 10.14.4) where trying to increase the stack limit at run time using resource.RLIMIT_STACK fails.  If you do need to increase the stack limit, to handle deeper recusions etc, one solution is to rebuild Python for macOS with a larger stack size as shown in PR 14546 rather than trying to change it at runtime.
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84698
2020-05-06 00:00:00ned.deilysetstatus: open -> closed
superseder: python3 resource.setrlimit strange behaviour under macOS
messages: + msg368214

resolution: duplicate
stage: resolved
2020-05-05 14:05:11corona10setnosy: + corona10
2020-05-05 13:57:38morioprogcreate