resource module

Thomas Wouters thomas at xs4all.net
Wed Mar 19 11:29:36 CET 2003


On Tue, Mar 18, 2003 at 07:39:43PM -0500, Jp Calderone wrote:

>   I've looked at this module several times over the years.  It seems to have
> been in a perpetual state of undocumented brokeness.

>   Has anyone used it successfully?  If so, how?  In particular, I would like
> to reduce the number of allowed open files.

>>> resource.getrlimit(resource.RLIMIT_OFILE)
(1024L, 1024L)
>>> resource.setrlimit(resource.RLIMIT_OFILE, (10, 10))
>>> resource.getrlimit(resource.RLIMIT_OFILE)
(10L, 10L)
>>> files = []
>>> for i in range(15): files.append(open("/etc/passwd"))
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 24] Too many open files: '/etc/passwd'
>>> len(files)
7

I've used it a few times, and it's used in the test suite (regrtest.py
raises the soft stacklimit on Darwin.)

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!





More information about the Python-list mailing list