ulimit stack size and python threads

Andrew MacIntyre andymac at bullseye.apana.org.au
Fri Jan 9 00:06:47 CET 2009


Greg Lindahl wrote:
> I figure this is a FAQ, but I can't find it in any FAQs.
> 
> I want to limit the stacksize on my server.
> 
> If I set it to 8 megs, or unlimited, python is happy.
> 
> If I set it to 4 gigabytes, things like yum (which is a python
> program) crash creating a thread. This is on an x86_64 linux kernel,
> RHEL5, etc etc.
> 
> Why is Python overloading the meaning of the ulimit -s like this?
> There are plenty of real non-python programs with huge stack usage,
> and I'd like my system default stack limit to be less than unlimited
> but much larger than Python will allow.

The Python interpreter itself (absent a call to resource.setrlimit())
does nothing with resource limits - it just uses the environment it is
loaded into.

In the absence of effective alternative solutions, it may be possible to
achieve the effect you desire by calling resource.setrlimit() in your
Python installation's site.py, effectively over-riding the system
default.

-- 
-------------------------------------------------------------------------
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia



More information about the Python-list mailing list